Interface ReplaceOneOptions

Represents the options for the replaceOne command.

Field

upsert - If true, perform an insert if no documents match the filter.

Field

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

Field

vector - An optional vector to use of the appropriate dimensionality to perform an ANN vector search on the collection.

See

Collection.replaceOne

interface ReplaceOneOptions {
    maxTimeMS?: number;
    sort?: Sort;
    upsert?: boolean;
    vector?: number[];
    vectorize?: string;
}

Hierarchy (view full)

Properties

maxTimeMS?: number

The maximum time to wait for a response from the server, in milliseconds.

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
upsert?: boolean

If true, perform an insert if no documents match the filter.

If false, do not insert if no documents match the filter.

Defaults to false.

Default Value

false
vector?: number[]

An optional vector to use of the appropriate dimensionality to perform an ANN vector search on the collection to find the closest matching document.

This is purely for the user's convenience and intuitiveness—it is equivalent to setting the $vector field in the sort field itself. The two are interchangeable, but mutually exclusive.

If the sort field is already set, an error will be thrown. If you really need to use both, you can set the $vector field in the sort object directly.

Deprecated

  • Prefer to use sort: { $vector: [...] } instead
vectorize?: string

NOTE: This feature is under current development.

Deprecated

  • Prefer to use sort: { $vectorize: '...' } instead