mongodb query for results -
[ { "userid": "abcde", "dates": { "2-01-2015": { "9-10": { "ava": "yes", "bookibg_id": "null" }, "10-11": { "ava": "yes", "bookibg_id": "null" } }, "3-01-2015": { "9-10": { "ava": "no", "bookibg_id": "null" }, "10-11": { "ava": "no", "bookibg_id": "null" } } } }, { "userid": "abcde", "dates": { "2-01-2015": { "9-10": { "ava": "yes", "bookibg_id": "null" }, "10-11": { "ava": "no", "bookibg_id": "null" } }, "3-01-2015": { "9-10": { "ava": "no", "bookibg_id": "null" }, "10-11": { "ava": "no", "bookibg_id": "null" } } } } ]
i relatively new nosql db , mongodb.its kind of confusing how query these. given db how write query generate results: query:list userids such @ "2-01-2015",the "ava" "yes" @ "9-10". plzz explain results.
you can find using
db.coll.find({'dates.2-01-2015.9-10.ava': "yes"},{"userid":1,'_id':0})
here 'dates.2-01-2015.9-10.ava':'yes' used find value of ava yes similary accessing value json objects , second argument used userid query {"userid":1,'_id':0}
the output
{ "userid" : "abcde" } { "userid" : "abcde" }
if remove second argument you'll entire document in result based on second argument can filter feilds want
Comments
Post a Comment