0

I have a JSON schema that looks like 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 the scenes look at the making of A Tiger in the Dark: The Decadence Saga.", "poster" : null, "imdb" : { "id" : "tt2199902", "rating" : 8, "votes" : 50 }, "awards" : { "wins" : 0, "nominations" : 0, "text" : "" }, "type" : "movie" } 

I am trying to find a movie released in 2013, that is rated PG-13 and has won no awards. I tried the following query in my Mongo Shell but no luck:

db.movieDetails.find({rated: "PG-13", year:2013, awards: { wins : 0}}) 

Any ideas?

2 Answers 2

2

From the documentation:

When the field holds an embedded document, a query can either specify an exact match on the embedded document or specify a match by individual fields in the embedded document using the dot notation

db.movieDetails.find( { "rated": "PG-13", "year": 2013, "awards.wins" : 0 } ) 
Sign up to request clarification or add additional context in comments.

Comments

0

if this PG-13 rating query would work for you:

db.movieDetails.find({"rated": "PG-13"})

then i would try something like this:

db.movieDetails.find({$and: [{"rated": "PG-13"}, {"year": 2013}, {"awards": { "wins" : 0}}]} )

1 Comment

does this one without the awards work? db.movieDetails.find({$and: [{"rated": "PG-13"}, {"year": 2013}]} )

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.