INNER CODE UNIT · JavaScript

retryable

ramiel/mongoose-sequence · lib/sequence.js:363

    const retryable = (cb) => {
      const id = this.getId();
      const referenceValue = this._getCounterReferenceField(doc);
      const incAmount = this._options.inc_amount;
      this._counterModel
        .findOneAndUpdate(
          { id, reference_value: referenceValue },
          { $inc: { seq: incAmount } },
          { new: true, upsert: false },
        )
        .then((counter) => {
          cb(null, counter.seq);
        })
        .catch((err) => {
          cb(err);
        });
    };

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…