Reputation: 1563
I'd like to fetch some Documents where a field can possibly be $in
some array (conditional query if a filter was set).
However, I need to also unconditionally check whether this same field is $ne: null
. I understand the $in: [some values]
can be used to prevent null from being retrieved, but the problem is that part of the query is conditional based on if a filter is set.
Is there a more efficient way of doing what's below? Will that even work?
db.Parents.fetch({
childId: { $in: childIds },
childId: { $ne: null }
});
Upvotes: 0
Views: 1146