Reputation: 1027
I have Document in MongoDB like this:
{"ONE": {"TWO": {"THREE":"5"}}}
I want to query mongoDb using the Pymongo find
API, but it's not working:
for value in dbaccess.find({"ONE":{"TWO":{"THREE":{"$gt":"0"}}}}):
print value
Nothing is getting printed with the above code.
Upvotes: 9
Views: 6732
Reputation: 312149
Two things:
Use dot notation for querying nested documents:
dbaccess.find("ONE.TWO.THREE": {"$gt": 0})
Upvotes: 14