I have a calendar document like below
calendar: [
{days: {
1: [],
2: ['surprise'],
3: [],
...
}},
{days: {
1: [],
2: [],
3: ['test'],
...
}}
]
I'm trying to find words wherever are they then pull them from array. Here's my code:
var words = ['test']
Calendar.update(
{$or: [
{"calendar.days.1": {$in: words}},
{"calendar.days.2": {$in: words}}
]},
{$pull:
{$or:
{"calendar.days.1": {$in: words}},
{"calendar.days.2": {$in: words}}
}
},
{multi: true}
)
First part is working correctly. It finds documents which have words. But in the second part it's not deleting the words from array. Returns that log:
{ ok: 0, n: 0, nModified: 0 }
Any helps?
daysan array or an object with keys 1, 2, 3?