mongoose - how to get the matching document inside a array in mongodb? -


my collection this

{  _id :"",  name:[   {    firstname:"",    lastname:"",   }  ] } 

i need find matching firstname in documents. how achieve in query ? new mongodb.

db.collection.find({name: {$elemmatch: {firstname: "raj"}}}); 

for further details check out documentation $elemmatch


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -