Reputation: 8629
I want to return all documents in mongo that have a value for a field. For instance, I want to return all documents where name is not null:
db.people.find({name: "not null"})
How do I do this in Mongo DB?
Upvotes: 1
Views: 64
Reputation: 191799
Use $ne
with null
db.people.find({name: {$ne: null}})
$exists
will still find a record where name
is actually null
.
Upvotes: 3