node-mongo
node-mongo copied to clipboard
Atomic operations are not validated, _id is different, createdOn and updatedOn is not generated
I need to use upsert and $setOnUpsert to provide idempotency based on unique external id. It is not possible with the regular update/findOneAndUpdate but with atomic I got problems described in the title
cardService.atomic.findOneAndUpdate({ cardProxy }, ({
$set: _.omit(card, ['_id', 'cardProxy']),
$setOnInsert: { _id: cardService.generateId() },
}), { upsert: true });