pymongo - how to test for empty mongodb query in pymong -
how test query no results in pymongo?
x = collection.find( { "$and" : [ { "$or" : [ {"template":"template3.1"} , {"type" : "gift"} ] }, {"to":"test@test.com"} ] } )
can test if x
has returned nothing before doing data?
use cursor method count() check number of documents in cursor.
if x.count()>0: //use cursor
Comments
Post a Comment