I am trying to find all Documents/objects which contain false as one of their field’s values.
The Collection in question has a single Document:
{
_id: 758ab35de3a258foo,
Arr: [
{ str: "I am txt", bool: true },
{ str: "I am txt", bool: false},
...
]
}
Using collection.find() I have only been able to return the entire Document instead of returning only the Documents inside of the Arr array.
I have tried:
collection.find({ "Arr.bool": false }
collection.find({ "Arr": { $elemMatch: {"bool": false} }
collection.find({ "Arr": {
$elemMatch: {
$ne: { "bool": true }
}
}
So my questions are:
-
Is this the best structure/model I should be using for this Collection? [There will probably only be a few more Documents added]
-
Is it possible to get the results I am looking for using collection.find() alone, or is it necessary to filter/map the results I am getting afterwards?
Thank you for your time, and to anyone willing to help!! I really do appreciate it <3