I have a bug that i can\'t resolve because for the first time it happen to me.
here is my query :
Pack.find(
{idclient: clientId }
Two parts to this one ...
First, the callback from a Mongoose find returns an array ... findOne will return a single object.
As far as the new lines go, mongoose documents have a toString() helper for console.log. It is likely adding the newlines for readability. Wrap the output in JSON.stringify (ie. console.log(JSON.stringify(pack))) prior to calling console.log and you will see the document as a string without the newlines. -http://mongoosejs.com/docs/api.html#document_Document-toString
find() returns an array, so use findOne(), thanks to Adam Wysocki.
Sometimes i'm stupid developper .
As Told Model.find() generates an array so here is how I approach the situation:
Kitten.find(function (err, kittens) {
if (err) return console.error(err);
kittens.forEach(function(kitten){
console.log(kitten.name);
});
});
This seems to me the most clear way to access the properties