I would like to add a new document with exsiting mongodb objectId.
I would like to add the whole updated document FullDocument to a different collection as a child object.
I get full document using “changeEvent.fullDocument”.
When I added full document, all the objectIds are stored as Object instead of ObjectId.
I would like to add it as ObjectId itself. When I logged Full document in trigger using console.log("document: " + JSON.stringify(doc));
I do get Id like below.
“document: {"_id":"63ed45a95a45d8af598ce37d","CreatedOn":"2023-02-15T20:50:49.784Z","ModifiedOn":"2023-02-15T20:50:49.784Z","CreatedBy":"someone","ModifiedBy":"someone","IsDeleted":false,"ColumnId":"63ecc8cc5a45d8af598ce33f","RowId":null,"AssetRowId":"60707b5d6d3a5d6157c00be7","EventId":"63c6510bbb6fd348248b07e5","ParentRowId":null,"Value":false,"IsFlagged":false,"LevelId":0,"CalculationError":null,"InspectionId":"63c6510bbb6fd348248b07e5_60707b5d6d3a5d6157c00be7_63ecc8cc5a45d8af598ce33f","EventAssetId":"63c6510bbb6fd348248b07e5_60707b5d6d3a5d6157c00be7","CategoryId":"63ecc8c95a45d8af598ce33d","CategoryName":"somecategory”,
I did try new BSON.ObjectId(_id), still it creates Object only and not ObjectId.
Please pour some ideas how to create objectId instead of Object.
Thank you,
Visha Shah