Comment puis-je obtenir un tableau de tous les documents dans mon modèle?
-
22-10-2019 - |
Question
myModel.find ({}, la fonction (err, modèles) {
console.log (models.toJSON ()); // Erreur: objet n'a pas de méthode toJSON
})
La solution
Vous avez presque, mais vous devez utiliser JSON.stringify () au lieu de toJSON ():
myModel.find({}, function(err, models){
console.log(JSON.stringify(models));
})
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow