So I'm attempting to find all records who have a field set and isn't null.
I try using $exists
, however according to the MongoDB documentation, this query will return fields who equal null.
$exists
does match documents that contain the field that stores the null value.
So I'm now assuming I'll have to do something like this:
db.collection.find({ "fieldToCheck" : { $exists : true, $not : null } })
Whenever I try this however, I get the error [invalid use of $not]
Anyone have an idea of how to query for this?