Mongodb: $ match only if the object is empty

I want $matchonly empty objects in mine aggregate(). Is it possible? I know $exists, but a {}boolean true, so I'm stuck.

+4
source share
1 answer

Did you try to just use {field: {}}?

For instance:

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

Source: https://habr.com/ru/post/1666237/


All Articles