I have the following data inside a mongoose collection:
{
map: 'Sydney',
Postcode: 2000,
mapItems: [
{
team: 'NONE',
teamIcon: 20,
x: 0.6092914,
y: 0.28168318,
flags: 0
},
{
team: 'Alpha',
teamIcon: 33,
x: 0.63026464,
y: 0.41642973,
flags: 0
},
{
team: 'Bravo',
teamIcon: 20,
x: 0.63026464,
y: 0.41642973,
flags: 0
},
{
team: 'Alpha',
teamIcon: 20,
x: 0.63026464,
y: 0.41642973,
flags: 0
}
}
I'm trying to return just the mapItems that have the team as "Alpha" and teamIcon is 33 or 52.
dyDB
.find({
$or: [
{
"mapItems.teamIcon": 33,
},
{
"mapItems.teamIcon": 52,
},
],
$and: [
{
"mapItems.teamId": "Alpha" },
},
],
})
.then((data) => {
for (const dyn of data) {
console.log(dyn);
}
});
But it just returns everything and doesn't seem to filter it. I'm not sure what else to try. Can anyone give some pointers?