Hi,
I am trying with no luck in Mongo6.0 to add a field to Metadata. For each document, this field is going to have value of another field (called registerId) from the same document. The existing Metadata object contains 2 fields siteId and organizationId. I am looking to add one more field to Metadata called registerId by copying registerId field for each document.
Tried multiple ways. All of them add the field registerId to Metadata as expected but the value is string ‘$registerId’ instead of the value of registerId field.
db.litmusDataPoint.aggregate([{$set:{'Metadata.registerId':'$registerId'}}])
db.litmusDataPoint.updateMany({}, {$set: {"Metadata.registerId": "$registerId"}})
Is it not possible to dynamically set value of metaData filed in Mongo 6.0?