I am currently working with a calendar
document structured as shown below:
calendar: [
{days: {
1: [],
2: ['surprise'],
3: [],
...
}},
{days: {
1: [],
2: [],
3: ['test'],
...
}}
]
My task involves locating specific words within the array and then removing them. Below is the code I have been using:
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}
)
The first part of the code functions correctly by identifying documents containing the specified words. However, the second part fails to delete the words from the array. A log message displaying "{ ok: 0, n: 0, nModified: 0 }" is returned.
Any assistance would be greatly appreciated.