Interface GenericFindOneAndDeleteOptions

Represents the options for the findOneAndDelete command.

Field

sort - The sort order to pick which document to delete if the filter selects multiple documents.

Field

projection - Specifies which fields should be included/excluded in the returned documents.

Field

timeout - The timeout override for this method

See

Collection.findOneAndDelete

interface GenericFindOneAndDeleteOptions {
    maxTimeMS?: "ERROR: The `maxTimeMS` option is no longer available; the timeouts system has been overhauled, and timeouts should now be set using `timeout`";
    projection?: Projection;
    sort?: Sort;
    timeout?: number | Pick<Partial<TimeoutDescriptor>, "requestTimeoutMs" | "generalMethodTimeoutMs">;
    vector?: "ERROR: Use `sort: { $vector: [...] }` instead";
    vectorize?: "ERROR: Use `sort: { $vectorize: \"...\" }` instead";
}

Hierarchy (view full)

  • WithTimeout<"generalMethodTimeoutMs">
    • GenericFindOneAndDeleteOptions

Properties

maxTimeMS?: "ERROR: The `maxTimeMS` option is no longer available; the timeouts system has been overhauled, and timeouts should now be set using `timeout`"

This temporary error-ing property exists for migration convenience, and will be removed in a future version.

Deprecated

  • The maxTimeMS option is no longer available; the timeouts system has been overhauled, and timeouts should now be set using timeout, and defaults in timeoutDefaults. You may generally Ctrl+R replace maxTimeMS with timeout to retain the same behavior.
projection?: Projection

Specifies which fields should be included/excluded in the returned documents.

If not specified, all fields are included.

When specifying a projection, it's the user's responsibility to handle the return type carefully, as the projection will, of course, affect the shape of the returned documents. It may be a good idea to cast the returned documents into a type that reflects the projection to avoid runtime errors.

Example

interface User {
name: string;
age: number;
}

const collection = db.collection<User>('users');

const doc = await collection.findOne({}, {
projection: {
_id: 0,
name: 1,
},
vector: [.12, .52, .32],
includeSimilarity: true,
}) as { name: string, $similarity: number };

// Ok
console.log(doc.name);
console.log(doc.$similarity);

// Causes type error
console.log(doc._id);
console.log(doc.age);
sort?: Sort

The order in which to apply the update if the filter selects multiple documents.

If multiple documents match the filter, only one will be updated.

Defaults to null, where the order is not guaranteed.

Default Value

null
timeout?: number | Pick<Partial<TimeoutDescriptor>, "requestTimeoutMs" | "generalMethodTimeoutMs">

The method timeout override.

See TimeoutDescriptor for much more information.

vector?: "ERROR: Use `sort: { $vector: [...] }` instead"

This temporary error-ing property exists for migration convenience, and will be removed in a future version.

Deprecated

  • Use sort: { $vector: [...] } instead.
vectorize?: "ERROR: Use `sort: { $vectorize: \"...\" }` instead"

This temporary error-ing property exists for migration convenience, and will be removed in a future version.

Deprecated

  • Use sort: { $vectorize: '...' } instead.