Say I’d like to replace one ID by another inside an array (the target
field )
const id1 = new ObjectId(), id2 = new ObjectId(), id3 = new ObjectId();
await coll.insertMany([
{ targets: [id1, id2] },
{ targets: [id1] },
{ targets: [id2] },
]);
await coll.aggregate([
{ $set: { target: {.... } } } // replace all id1 by id3
])
// desired output for coll.find()
/*[
{ targets: [id3, id2] },
{ targets: [id3] },
{ targets: [id2] },
]*/
Could you guide me on what the aggregation operator should be?