Query not working - MongoDB -
given kind of documents:
"_id" : objectid("5461c8f0426f727f16010000"), "f" : [ { "t" : "ry", "v" : 1972 }, { "t" : "g", "v" : [ "crime", "drama" ] }, { "t" : "ml", "v" : "english" }, { "t" : "k", "v" : "movie" }, { "t" : "ai", "v" : 972353 }, { "t" : "ec", "v" : 46 }, { "t" : "rel", "v" : true } ] } i want query "ry" greater 1980 , "g" (genre) "drama" or "thriller".
i made query:
db.items.find( { "$or": [ {"f": $elemmatch: {"t": "ry", "v": {$gt: 1980}}}, {"f": $elemmatch: {"t": "g", "v": {$in: ["drama"]}}} ] } ) but not working:
error: line 4: unexpected token :
any idea why this?
looks you've missed brackets before $elemmatch:
db.items.find( { "$or": [ {"f": {$elemmatch: {"t": "ry", "v": {$gt: 1980}}}}, {"f": {$elemmatch: {"t": "g", "v": {$in: ["drama"]}}}} ] } )
Comments
Post a Comment