Type alias CollectionReplaceOneResult<RSchema>

CollectionReplaceOneResult<RSchema>: GenericUpdateResult<IdOf<RSchema>, 0 | 1>

Represents the result of a replaceOne operation.

Type Parameters

  • RSchema

Example

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

if (result.upsertedCount) {
  console.log(`Document with ID ${result.upsertedId} was upserted`);
}

Field

matchedCount - The number of documents that matched the filter.

Field

modifiedCount - The number of documents that were actually modified.

Field

upsertedCount - The number of documents that were upserted.

Field

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

See

Collection.replaceOne