mongodb - Mongo query not returning a result -
i'm trying first mongodb query on following json document added database using mongoimport.
{ "questions": [ { "questionentry": { "id": 1, "info": { "seasonnumber": 1, "episodenumber": 1, "episodename": "days gone bye" }, "questionitem": { "thequestion": "q1", "attachedelement": { "type": 1, "value": "" } }, "options": [ { "type": 1, "value": "o1" }, { "type": 1, "value": "o1" } ], "answer": { "questionid": 1, "answer": 1 }, "metatags": [ "season 1", "episode 1", "rick grimmes" ] } }, { "questionentry": { "id": 1, "info": { "seasonnumber": 1, "episodenumber": 1, "episodename": "days gone bye" }, "questionitem": { "thequestion": "q2", "attachedelement": { "type": 1, "value": "" } }, "options": [ { "type": 1, "value": "o2" }, { "type": 1, "value": "o2" } ], "answer": { "questionid": 1, "answer": 1 }, "metatags": [ "season 1", "episode 1", "rick grimmes", "glenn rhee" ] } } ] } i have tried db.questions.find({"questions.questionentry.id" : "1"}) & db.questions.find({"questions.questionentry.id" : "1"}) plus several other versions try , query id field of questionentry. every time command prompt returns new command prompt line "nothing"!?
if run db.questions.find() returns collection shown above.
what have/am doing wrong here?
your id number, not string.
so following should work:
db.questions.find({"questions.questionentry.id" : 1})
Comments
Post a Comment