MongoDB Querying for object property in list MongoDB Querying for object property in list mongodb mongodb

MongoDB Querying for object property in list


Something like:

db.foo.find({"comments.user":"karl", "comments.at":{$gt:{dateObject}});

Haven't tested but you get the idea; you can drill down on items as such.

I'd recommend going through this site as it drives you through a great deal of interactive tutorials: Interactive Tutorial


You should use $elemMatch to match more than one conditions in same doc.

Something like:

db.foo.find({comments: {"$elemMatch": {user: "karl", at: {$gt:{dateObject}}}})

See here for more details.