Mongodb Query To select records having a given key

Posted by sagar on Stack Overflow See other posts from Stack Overflow or by sagar
Published on 2011-01-03T05:57:23Z Indexed on 2011/01/04 5:54 UTC
Read the original article Hit count: 486

Filed under:

let the records in database are

{"_id":"1","fn":"sagar","ln":"Varpe"}

{"_id":"1","fn":"sag","score":"10"}

{"_id":"1","ln":"ln1","score":"10"}

{"_id":"1","ln":"ln2"} 

I need to design a MongoDB query to find all records who has a given key

like if i pass "ln" as a parameter to query it shold return all records in which "ln"is a Key , the results fo are

{"_id":"1","fn":"sagar","ln":"Varpe"}

{"_id":"1","ln":"ln1","score":"10"}

{"_id":"1","ln":"ln2"} 

© Stack Overflow or respective owner

Related posts about mongodb