Hi, according with Change Stream documentation
There is an example
const pipeline = [
{ $match: { 'fullDocument.username': 'alice' } },
{ $addFields: { newField: 'this is an added field!' } }
];
const collection = db.collection('inventory');
const changeStream = collection.watch(pipeline);
changeStream.on('change', next => {
// process next document
});
This means that the document will be modified and a new saved attribute newField
will be added right?
I performed this operation, and it didn’t happen, I capture the event, I added a field , I even needed to add it inside fullDocument.
i put log, and the new attribute appears in the log, but it does not persist on database.
const pipeline = [
{
$match: { operationType: { $in: ['insert'] } },
},
{
$addFields: { fullDocument: { createdAt: new Date(), handled: true } },
},
{ $project: { fullDocument: 1 } },
];```
Is there something wrong, or did I get it wrong?
Thanks in advance.