orm – Node. Mongodb / mongoose. JS Find by ID of nested document

For some reason, when I search through the ID of a nested document, I can't find the document I can easily perform other lookups, so these two tasks:

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

However, ID lookup through nested doc does not work:

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

I can perform searches in the Mongo shell, but not through mongoose Any idea will help

Solution

I added it as a question in the project

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>