Answer the question
In order to leave comments, you need to log in
MongoDb. How to find dictionary element by key value?
db = client.test
collection=db.test_collection
test_inf={"test1":"test2"}
collection.save(test_inf)
if collection.find(["test1"]):print("yes")
Answer the question
In order to leave comments, you need to log in
If I understand the problem correctly, then you need to use the $exists operator link to the dock
Example code:
db = client.test
collection=db.test_collection
test_inf={"test1":"test2"}
collection.save(test_inf)
// применяем оператор $exists
collection.find({ "test1" : { "$exists" : true } })
// Но вот так не работает
if collection.find({ "test1" : { "$exists" : true } }):print("yes")
// А так работает
collection.find({ "test1" : { "$exists" : true } }) && print("yes")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question