I’d like to simplify $set (aka $addFields) and $project because they look redundant
Is there maybe an operator allowing to rewrite entirely the $$CURRENT doc to achieve the same result of those 2 steps?
coll.aggregate([
{ $match: { ...} },
{ $lookup: { .... },
{ $unwind: '$accounts' },
{ $set: { _id: '$accounts._id', deleted: true, deletedAt: date } },
{ $project: { _id: 1, deleted: 1, deletedAt: 1 } },
{ $merge: { into: 'accounts', whenNotMatched: 'discard' } },
])