Whats the behavior of Pymongo find_one
? I would expect such a function to return a None or throw an exception when it does not find the required document. But it behaves like:
>>> q = db.find_one({'node_type': {'$regex':'impossible-condition'}})
>>> q
>>>
>>> q==1
False
>>> w==1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'w' is not defined
Does it return anything? And how to safely determine if the query did not match a value?