Hi All,
I have a collection of document types and I want to track update changes in all documents for a selected field that is of object type. Here is an example for the selected field:
“00741000”: {
“vr”: “CS”,
“Value”: [
“READY”
]
}
According the sources I found, I’m using watch method with this aggregation pipeline:
pipeline = [{
‘$match’: {
‘operationType’: ‘update’,
‘updateDescription.updatedFields.00741000.Value.0’: {“$exists”: True }
}
}
]
The problem is that the function can’t catch any updates for the selected field. However, if I used the watch method without pipeline the output I got would be this:
“_id”: {
“_data”: “82665988BA000000022B042C0100296E5A1004AED791D1B20B4C45ADA18D58E4DD0378463C6F7065726174696F6E54797065003C7570646174650046646F63756D656E744B65790046645F6964006466320B28E5E106145AEA08B8000004”
},
“operationType”: “update”,
“clusterTime”: {
“$timestamp”: {
“t”: 1717143738,
“i”: 2
}
},
“wallTime”: {
“$date”: “2024-05-31T08:22:18.389Z”
},
“ns”: {
“db”: “ups”,
“coll”: “ups”
},
“documentKey”: {
“_id”: {
“$oid”: “66320b28e5e106145aea08b8”
}
},
“updateDescription”: {
“updatedFields”: {
“00741000.Value.0”: “SCHEDULED”
},
“removedFields”: ,
“truncatedArrays”:
}
}
I also noticed that if the data type of the field ‘00741000’ is string, I can track changes using this pipeline:
pipeline = [{
‘$match’: {
‘operationType’: ‘update’,
'updateDescription.updatedFields.00741000: {“$exists”: True }
}
}
]
I assume the cause of the problem has something to do with the path of the object in the pipeline script. Does anyone know how I can fix this problem? I’m pretty new to MongoDB and I haven’t found any resources to fix this, thank you.