Suppose I have these documents:
[
{
_id: 132143124,
orders: [true, false, false],
},
{
_id: 3123,
orders: [true, true, true],
},
];
How do I get only the documents that dont have ‘false’ in their orders array.
I need an aggregate stage solution. ( MongoDB aggregate solution )
>Solution :
You can use $not or $ne ( as Mongo’s query language flattens arrays ) for this, like so:
db.collection.find({
orders: {$ne: false}
})
same syntax will work in the aggregation pipeline:
Mongo Playground Aggregation