I'm trying to run a MongoDB query and return those records where a field is null (more specifically None in pyMongo). So it has to be equal to null.
I know this is not equal to:
{"firstName": {"$ne": None }}
I can't find the equal operator in the documentation.
Thanks
{"firstName":{ $type: 10 } } should give you what you want
http://docs.mongodb.org/manual/faq/developers/#faq-developers-query-for-nulls
If you want to find records having firstName defined in record with value None defined:
db.testcoll.find({$and: [{"firstName": None}, {"firstName": {$exists: true}}]})
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