How am I able to watch only updates in "orders" field of array? For example, an item was added or removed from array.
I found a code below that should have solved the issue, but it only works if the field is not an array.
Data:
{
"title": "hello",
"orders": [Object]
}
Code:
var pipeline = [
{
$match: {
$and: [
{'updateDescription.updatedFields.orders': {$exists: true}},
{operationType: 'update'},
],
},
},
];
var options = {fullDocument: 'updateLookup'};
const restaurants = connection
.collection('restaurants')
.watch(pipeline, options);