Querying in mongoDB database using python


"_id" : ObjectId(“577a318669c9e39da0f3f5ea”),
“file_name” : “jsformat.txt”,
“contents” : “{“upordown”: “up”, “lkl”: “1.24”, “qop”: “0.94”, “ret”: “average”, “yui”: “1.09”, “hjk”: “load”, “time”: “00:03:31”, “dfg”: “2”, “ds”: “9:11”, “ghj”: “users”}”

This is how the my data is stored in the database. but i am not able to retrieve it without using objectid
when i write db.collection.find({“upordown”:“up”}) it is showing me NULL


Looks like your contents wasn’t stored as Object (JSON) but as string (stringified JSON)


I agree with @jamgold that it looks like contents was stored as a string instead of a nested doc (javascript object). If you do manage to store it correctly the query should read:
db.collection.find({"contents.upordown": "up"})


the problem is solved. Thank you