MongoDB: How to query for records where field is null or not set?
If the sent_at field is not there when its not set then: db.emails.count({sent_at: {$exists: false}}) If it’s there and null, or not there at all: db.emails.count({sent_at: null}) If it’s there and null: db.emails.count({sent_at: { $type: 10 }}) The Query for Null or Missing Fields section of the MongoDB manual describes how to query for null … Read more