at least one in mongodb

1999 views mongodb
8

I have a database related to movies. This is how i inserted my data in the database:
db.Movieinfo.insert({ "MovieID":1, "MovieName":"iron man", "Actor":"Robert downey", "ReleaseDate":2008, "GotOscars":1,
}) But when i do the following to get the list of movies which returns only movies that have won at least one oscar or more: db.Movieinfo.find({"MovieName":1},{"GotOscars":{$gte:1}}), it gives all the movies that haven't won oscar also. Could anyone please help me with this? Thank you in advance.

answered question

db.Movieinfo.find({ "GotOscars":{$gte:1} })

1 Answer

12

try this

db.Movieinfo.find({"GotOscars":{$gte:1}})

https://docs.mongodb.com/manual/reference/method/db.collection.find/ you were passing 2 arguments and another argument was considered as projection.

posted this

Have an answer?

JD

Please login first before posting an answer.