Hello!
As stated in the db.collection.watch() documentation:
Starting in MongoDB 6.0, you can use the new fullDocumentBeforeChange field and set it to:
“whenAvailable” to output the document pre-image, if available, before the document was replaced, updated, or deleted.
I would like to understand under which circumstances the fullDocumentBeforeChange would not be available.
I’m using MongoDB v6.0 dedicated on Atlas
Details
Document in DB before change:
{
"_id": "65f4c121ac8791800bdca1ef",
"arrayLevel1": [
{
"title": "level1",
"arrayLevel2": [
{
"title": "level2",
"property": "value",
"name": "John",
"age": 30
}
]
}
]
}
Update:
await client()
.collection('testStreams')
.updateOne(
{
_id: getObjectId('65f4c121ac8791800bdca1ef'),
},
{
$set: {
'arrayLevel1.0.arrayLevel2.0.age': 40,
},
}
);
Next result:
{
...
"operationType": "update",
"fullDocument": {
"_id": "65f4c121ac8791800bdca1ef",
"arrayLevel1": [
{
"title": "level1",
"arrayLevel2": [
{
"title": "level2",
"property": "value",
"name": "John",
"age": 40
}
]
}
]
},
"updateDescription": {
"updatedFields": {
"arrayLevel1.0.arrayLevel2.0.age": 40
},
"removedFields": [],
"truncatedArrays": []
},
"fullDocumentBeforeChange": null
}
Why in the above stream change the fullDocumentBeforeChange is null?
Thanks!!