Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb/Mongoose in Node.js. Finding by id of the nested document

For some reason I can't find a document when I search by the id of a nested document. I can perform other finds easily enough so these two work:

User.findOne({"_id" : some_id}, function(err,user){}
User.findOne({"arrayOfNestedDocs.value":someValue}, function(err,user){}

But finding by id of nested doc doesn't work:

User.findOne({"arrayOfNestedDocs._id" : some_id}, function(err,user){}

I can perform the search in a mongo shell so but not via mongoose. Any ideas would be helpful.

like image 652
henry.oswald Avatar asked Nov 14 '22 21:11

henry.oswald


1 Answers

I've added it as an issue in the project

like image 89
henry.oswald Avatar answered Nov 16 '22 18:11

henry.oswald