import type { Document, ObjectId } from '../bson'; import type { Collection } from '../collection'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { Callback, MongoDBNamespace } from '../utils'; import { CollationOptions, CommandOperation, CommandOperationOptions } from './command'; import { Hint } from './operation'; /** @public */ export interface UpdateOptions extends CommandOperationOptions { /** A set of filters specifying to which array elements an update should apply */ arrayFilters?: Document[]; /** If true, allows the write to opt-out of document level validation */ bypassDocumentValidation?: boolean; /** Specifies a collation */ collation?: CollationOptions; /** Specify that the update query should only consider plans using the hinted index */ hint?: string | Document; /** When true, creates a new document if no document matches the query */ upsert?: boolean; /** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */ let?: Document; } /** @public */ export interface UpdateResult { /** Indicates whether this write result was acknowledged. If not, then all other members of this result will be undefined */ acknowledged: boolean; /** The number of documents that matched the filter */ matchedCount: number; /** The number of documents that were modified */ modifiedCount: number; /** The number of documents that were upserted */ upsertedCount: number; /** The identifier of the inserted document if an upsert took place */ upsertedId: ObjectId; } /** @public */ export interface UpdateStatement { /** The query that matches documents to update. */ q: Document; /** The modifications to apply. */ u: Document | Document[]; /** If true, perform an insert if no documents match the query. */ upsert?: boolean; /** If true, updates all documents that meet the query criteria. */ multi?: boolean; /** Specifies the collation to use for the operation. */ collation?: CollationOptions; /** An array of filter documents that determines which array elements to modify for an update operation on an array field. */ arrayFilters?: Document[]; /** A document or string that specifies the index to use to support the query predicate. */ hint?: Hint; } /** @internal */ export declare class UpdateOperation extends CommandOperation { options: UpdateOptions & { ordered?: boolean; }; statements: UpdateStatement[]; constructor(ns: MongoDBNamespace, statements: UpdateStatement[], options: UpdateOptions & { ordered?: boolean; }); get canRetryWrite(): boolean; execute(server: Server, session: ClientSession | undefined, callback: Callback): void; } /** @internal */ export declare class UpdateOneOperation extends UpdateOperation { constructor(collection: Collection, filter: Document, update: Document, options: UpdateOptions); execute(server: Server, session: ClientSession | undefined, callback: Callback): void; } /** @internal */ export declare class UpdateManyOperation extends UpdateOperation { constructor(collection: Collection, filter: Document, update: Document, options: UpdateOptions); execute(server: Server, session: ClientSession | undefined, callback: Callback): void; } /** @public */ export interface ReplaceOptions extends CommandOperationOptions { /** If true, allows the write to opt-out of document level validation */ bypassDocumentValidation?: boolean; /** Specifies a collation */ collation?: CollationOptions; /** Specify that the update query should only consider plans using the hinted index */ hint?: string | Document; /** When true, creates a new document if no document matches the query */ upsert?: boolean; /** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */ let?: Document; } /** @internal */ export declare class ReplaceOneOperation extends UpdateOperation { constructor(collection: Collection, filter: Document, replacement: Document, options: ReplaceOptions); execute(server: Server, session: ClientSession | undefined, callback: Callback): void; } export declare function makeUpdateStatement(filter: Document, update: Document, options: UpdateOptions & { multi?: boolean; }): UpdateStatement; //# sourceMappingURL=update.d.ts.map