2

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.

0

1 Answer 1

6

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

For example:

db.users.aggregate([{$match: {val: {}}}])
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, easier than I thought.
How can I do the opposite and match only no empty result ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.