at least one in mongodb

at least one in mongodb



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.


db.Movieinfo.find("MovieName":1,"GotOscars":$gte:1)






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

– Mohamed Sameer
Sep 16 '18 at 6:53




2 Answers
2



The mongoDB search query uses: db.collection.find(<query>, <projection>)


db.collection.find(<query>, <projection>)



To find the names of all movies with more or equal to one oscar use:


db.Movieinfo.find("GotOscars":$gte:1, "MovieName":1);



To find full movie details of movies with more or equal to one oscar use:


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



You can learn more about in the official documentation here.



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.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế