wscourge
wscourge

Reputation: 11301

Mongodb: aggregate $match only if object is empty

I want to $match only the empty objects in my aggregate(). Is it possible? I know of $exists, but {}'s boolean value is true, so I'm stuck.

Upvotes: 2

Views: 3891

Answers (1)

Alan Mroczek
Alan Mroczek

Reputation: 1199

Have you tried to just use {field: {}} ?

For example:

db.users.aggregate([{$match: {val: {}}}])

Upvotes: 6

Related Questions