node-mongo icon indicating copy to clipboard operation
node-mongo copied to clipboard

Atomic operations are not validated, _id is different, createdOn and updatedOn is not generated

Open alldayalone opened this issue 2 years ago • 3 comments

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 });

alldayalone avatar Oct 20 '21 07:10 alldayalone