How check for exist and empty in mongoose by find function?

Viewed 1062

I want to check some field for empty. the field can be null or not exist or empty array.

I did so far something does work but not cover when the "exist" or "null":

.find({ roles: { '$size': 0 } }, { projection: {} });

one important thing, it must start with .find({ roles: . so I can't use $or like in this answer. I need another solution for do it by pass a condition into roles object in find function.

Any ideas?

1 Answers
Related