Querying nested documents using Mongoose (MongoDB)

You can query an embedded document in mongoose like this

   User.find({'links.url':req.params.query}, function(err, foundUsers){
      // ---
   });

and to find the links that belong to the user “vlad”, you can write

   User.find({name:'vlad','links.url':req.params.query}, function(err, foundUsers){
      // ---
   });

This will do the trick.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)