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.
Two things:
Use dot notation for querying nested documents:
dbaccess.find("ONE.TWO.THREE": {"$gt": 0})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With