Type alias GenericUpdateResult<ID, N>

Represents the result of a generic update command using the Data API.

Type Parameters

  • ID
  • N extends number

Example

const result = await collection.updateOne({
  _id: 'abc'
}, {
  $set: { name: 'John' }
}, {
  upsert: true
});

if (result.upsertedCount) {
  console.log(`Record with identifier ${JSON.stringify(result.upsertedId)} was upserted`);
}

Field

matchedCount - The number of records that matched the filter.

Field

modifiedCount - The number of records that were actually modified.

Field

upsertedCount - The number of records that were upserted.

Field

upsertedId - The identifier of the upserted record if upsertedCount > 0.