Type alias CollectionUpdateOneResult<RSchema>

CollectionUpdateOneResult<RSchema>: GenericUpdateResult<IdOf<RSchema>, 0 | 1>
Overview

Represents the result of an updateOne command on a Collection.

🚨Important: The exact result type depends on the upsertedCount field of the result:

Type Parameters

  • RSchema

Example

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

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

See

  • Collection.updateOne
  • CollectionUpdateOneOptions