json - How do I query a nested object in MongoDB? -
i have json schema looks this:
{ "_id" : objectid("5692a3e124de1e0ce2dfda22"), "title" : "a decade of decadence, pt. 2: legacy of dreams", "year" : 2013, "rated" : "pg-13", "released" : isodate("2013-09-13t04:00:00z"), "runtime" : 65, "countries" : [ "usa" ], "genres" : [ "documentary" ], "director" : "drew glick", "writers" : [ "drew glick" ], "actors" : [ "gordon auld", "howie boulware jr.", "tod boulware", "chen drachman" ], "plot" : "a behind scenes @ making of tiger in dark: decadence saga.", "poster" : null, "imdb" : { "id" : "tt2199902", "rating" : 8, "votes" : 50 }, "awards" : { "wins" : 0, "nominations" : 0, "text" : "" }, "type" : "movie" }
i trying find movie released in 2013, rated pg-13 , has won no awards. tried following query in mongo shell no luck:
db.moviedetails.find({rated: "pg-13", year:2013, awards: { wins : 0}})
any ideas?
from documentation:
when field holds embedded document, query can either specify exact match on embedded document or specify match individual fields in embedded document using dot notation
db.moviedetails.find( { "rated": "pg-13", "year": 2013, "awards.wins" : 0 } )
Comments
Post a Comment