From cc171979383f7ff6217e82522eb68d74ec626390 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 8 May 2023 17:27:46 -0400 Subject: [PATCH] types: make `lean()` not clobber result type for `updateOne()`, etc. Fix #13382 --- test/types/lean.test.ts | 10 +++ types/models.d.ts | 166 +++++++++++++++++++++----------------- types/query.d.ts | 174 ++++++++++++++++++++++++++++++---------- 3 files changed, 237 insertions(+), 113 deletions(-) diff --git a/test/types/lean.test.ts b/test/types/lean.test.ts index b6f9e538038..745999d3aa0 100644 --- a/test/types/lean.test.ts +++ b/test/types/lean.test.ts @@ -196,3 +196,13 @@ async function gh13345_3() { const place = await PlaceModel.findOne().lean().orFail().exec(); expectAssignable(place); } + +async function gh13382() { + const schema = new Schema({ + name: String + }); + const Test = model('Test', schema); + + const res = await Test.updateOne({}, { name: 'bar' }).lean(); + expectAssignable<{ matchedCount: number, modifiedCount: number }>(res); +} diff --git a/types/models.d.ts b/types/models.d.ts index f112d8e514e..1efcd565063 100644 --- a/types/models.d.ts +++ b/types/models.d.ts @@ -193,17 +193,24 @@ declare module 'mongoose' { collection: Collection; /** Creates a `count` query: counts the number of documents that match `filter`. */ - count(filter?: FilterQuery): QueryWithHelpers; + count(filter?: FilterQuery): QueryWithHelpers< + number, + THydratedDocumentType, + TQueryHelpers, + TRawDocType, + 'count' + >; /** Creates a `countDocuments` query: counts the number of documents that match `filter`. */ countDocuments( filter?: FilterQuery, options?: QueryOptions ): QueryWithHelpers< - number, - THydratedDocumentType, - TQueryHelpers, - TRawDocType + number, + THydratedDocumentType, + TQueryHelpers, + TRawDocType, + 'countDocuments' >; /** Creates a new document or documents */ @@ -230,18 +237,20 @@ declare module 'mongoose' { filter?: FilterQuery, options?: QueryOptions ): QueryWithHelpers< - mongodb.DeleteResult, - THydratedDocumentType, - TQueryHelpers, - TRawDocType + mongodb.DeleteResult, + THydratedDocumentType, + TQueryHelpers, + TRawDocType, + 'deleteMany' >; deleteMany( filter: FilterQuery ): QueryWithHelpers< - mongodb.DeleteResult, - THydratedDocumentType, - TQueryHelpers, - TRawDocType + mongodb.DeleteResult, + THydratedDocumentType, + TQueryHelpers, + TRawDocType, + 'deleteMany' >; /** @@ -253,18 +262,20 @@ declare module 'mongoose' { filter?: FilterQuery, options?: QueryOptions ): QueryWithHelpers< - mongodb.DeleteResult, - THydratedDocumentType, - TQueryHelpers, - TRawDocType + mongodb.DeleteResult, + THydratedDocumentType, + TQueryHelpers, + TRawDocType, + 'deleteOne' >; deleteOne( filter: FilterQuery ): QueryWithHelpers< - mongodb.DeleteResult, - THydratedDocumentType, - TQueryHelpers, - TRawDocType + mongodb.DeleteResult, + THydratedDocumentType, + TQueryHelpers, + TRawDocType, + 'deleteOne' >; /** @@ -282,25 +293,25 @@ declare module 'mongoose' { id: any, projection?: ProjectionType | null, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; findById( id: any, projection?: ProjectionType | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Finds one document. */ findOne( filter?: FilterQuery, projection?: ProjectionType | null, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; findOne( filter?: FilterQuery, projection?: ProjectionType | null - ): QueryWithHelpers; + ): QueryWithHelpers; findOne( filter?: FilterQuery - ): QueryWithHelpers; + ): QueryWithHelpers; /** * Shortcut for creating a new Document from existing raw data, pre-saved in the DB. @@ -392,7 +403,7 @@ declare module 'mongoose' { watch(pipeline?: Array>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean }): mongodb.ChangeStream; /** Adds a `$where` clause to this query */ - $where(argument: string | Function): QueryWithHelpers, THydratedDocumentType, TQueryHelpers, TRawDocType>; + $where(argument: string | Function): QueryWithHelpers, THydratedDocumentType, TQueryHelpers, TRawDocType, 'find'>; /** Registered discriminators for this model. */ discriminators: { [name: string]: Model } | undefined; @@ -401,10 +412,22 @@ declare module 'mongoose' { translateAliases(raw: any): any; /** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */ - distinct(field: string, filter?: FilterQuery): QueryWithHelpers, THydratedDocumentType, TQueryHelpers, TRawDocType>; + distinct(field: string, filter?: FilterQuery): QueryWithHelpers< + Array, + THydratedDocumentType, + TQueryHelpers, + TRawDocType, + 'distinct' + >; /** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */ - estimatedDocumentCount(options?: QueryOptions): QueryWithHelpers; + estimatedDocumentCount(options?: QueryOptions): QueryWithHelpers< + number, + THydratedDocumentType, + TQueryHelpers, + TRawDocType, + 'estimatedDocumentCount' + >; /** * Returns a document with its `_id` if at least one document exists in the database that matches @@ -413,16 +436,18 @@ declare module 'mongoose' { exists( filter: FilterQuery ): QueryWithHelpers< - { _id: InferId } | null, - THydratedDocumentType, - TQueryHelpers, - TRawDocType + { _id: InferId } | null, + THydratedDocumentType, + TQueryHelpers, + TRawDocType, + 'findOne' >; exists(filter: FilterQuery): QueryWithHelpers< - { _id: InferId } | null, - THydratedDocumentType, - TQueryHelpers, - TRawDocType + { _id: InferId } | null, + THydratedDocumentType, + TQueryHelpers, + TRawDocType, + 'findOne' >; /** Creates a `find` query: gets a list of documents that match `filter`. */ @@ -430,107 +455,102 @@ declare module 'mongoose' { filter: FilterQuery, projection?: ProjectionType | null | undefined, options?: QueryOptions | null | undefined - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find'>; find( filter: FilterQuery, projection?: ProjectionType | null | undefined - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find'>; find( filter: FilterQuery - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find'>; find( - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find'>; /** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */ findByIdAndDelete( id?: mongodb.ObjectId | any, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findByIdAndRemove` query, filtering by the given `_id`. */ findByIdAndRemove( id?: mongodb.ObjectId | any, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */ findByIdAndUpdate( id: mongodb.ObjectId | any, update: UpdateQuery, options: QueryOptions & { rawResult: true } - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>; findByIdAndUpdate( id: mongodb.ObjectId | any, update: UpdateQuery, options: QueryOptions & { upsert: true } & ReturnsNewDoc - ): QueryWithHelpers; + ): QueryWithHelpers; findByIdAndUpdate( id?: mongodb.ObjectId | any, update?: UpdateQuery, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; findByIdAndUpdate( id: mongodb.ObjectId | any, update: UpdateQuery - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */ findOneAndDelete( filter?: FilterQuery, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findOneAndRemove` query: atomically finds the given document and deletes it. */ findOneAndRemove( filter?: FilterQuery, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */ findOneAndReplace( filter: FilterQuery, replacement: TRawDocType | AnyObject, options: QueryOptions & { rawResult: true } - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace'>; findOneAndReplace( filter: FilterQuery, replacement: TRawDocType | AnyObject, options: QueryOptions & { upsert: true } & ReturnsNewDoc - ): QueryWithHelpers; + ): QueryWithHelpers; findOneAndReplace( filter?: FilterQuery, replacement?: TRawDocType | AnyObject, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */ findOneAndUpdate( filter: FilterQuery, update: UpdateQuery, options: QueryOptions & { rawResult: true } - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>; findOneAndUpdate( filter: FilterQuery, update: UpdateQuery, options: QueryOptions & { upsert: true } & ReturnsNewDoc - ): QueryWithHelpers; + ): QueryWithHelpers; findOneAndUpdate( filter?: FilterQuery, update?: UpdateQuery, options?: QueryOptions | null - ): QueryWithHelpers; - - geoSearch( - filter?: FilterQuery, - options?: GeoSearchOptions - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType>; + ): QueryWithHelpers; /** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */ replaceOne( filter?: FilterQuery, replacement?: TRawDocType | AnyObject, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Schema the model uses. */ schema: Schema; @@ -540,31 +560,33 @@ declare module 'mongoose' { filter?: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */ updateOne( filter?: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a Query, applies the passed conditions, and returns the Query. */ where( path: string, val?: any - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find'>; where(obj: object): QueryWithHelpers< - Array, - ResultDoc, - TQueryHelpers, - TRawDocType + Array, + ResultDoc, + TQueryHelpers, + TRawDocType, + 'find' >; where(): QueryWithHelpers< - Array, - ResultDoc, - TQueryHelpers, - TRawDocType + Array, + ResultDoc, + TQueryHelpers, + TRawDocType, + 'find' >; } } diff --git a/types/query.d.ts b/types/query.d.ts index d08a1e345cc..540a4faf085 100644 --- a/types/query.d.ts +++ b/types/query.d.ts @@ -21,7 +21,7 @@ declare module 'mongoose' { type ProjectionFields = { [Key in keyof DocType]?: any } & Record; - type QueryWithHelpers = Query & THelpers; + type QueryWithHelpers = Query & THelpers; type QuerySelector = { // Comparison @@ -168,7 +168,9 @@ declare module 'mongoose' { [other: string]: any; } - class Query implements SessionOperation { + type QueryOpThatReturnsDocument = 'find' | 'findOne' | 'findOneAndUpdate' | 'findOneAndReplace' | 'findOneAndDelete'; + + class Query implements SessionOperation { _mongooseOptions: MongooseQueryOptions; /** @@ -181,7 +183,13 @@ declare module 'mongoose' { /** Executes the query */ exec(): Promise; - $where(argument: string | Function): QueryWithHelpers; + $where(argument: string | Function): QueryWithHelpers< + DocType[], + DocType, + THelpers, + RawDocType, + QueryOp + >; /** Specifies an `$all` query condition. When called with one argument, the most recent path passed to `where()` is used. */ all(path: string, val: Array): this; @@ -239,13 +247,19 @@ declare module 'mongoose' { comment(val: string): this; /** Specifies this query as a `count` query. */ - count(criteria?: FilterQuery): QueryWithHelpers; + count(criteria?: FilterQuery): QueryWithHelpers< + number, + DocType, + THelpers, + RawDocType, + 'count' + >; /** Specifies this query as a `countDocuments` query. */ countDocuments( criteria?: FilterQuery, options?: QueryOptions - ): QueryWithHelpers; + ): QueryWithHelpers; /** * Returns a wrapper around a [mongodb driver cursor](https://mongodb.github.io/node-mongodb-native/4.9/classes/FindCursor.html). @@ -258,21 +272,42 @@ declare module 'mongoose' { * remove, except it deletes _every_ document that matches `filter` in the * collection, regardless of the value of `single`. */ - deleteMany(filter?: FilterQuery, options?: QueryOptions): QueryWithHelpers; - deleteMany(filter: FilterQuery): QueryWithHelpers; - deleteMany(): QueryWithHelpers; + deleteMany( + filter?: FilterQuery, + options?: QueryOptions + ): QueryWithHelpers; + deleteMany(filter: FilterQuery): QueryWithHelpers< + any, + DocType, + THelpers, + RawDocType, + 'deleteMany' + >; + deleteMany(): QueryWithHelpers; /** * Declare and/or execute this query as a `deleteOne()` operation. Works like * remove, except it deletes at most one document regardless of the `single` * option. */ - deleteOne(filter?: FilterQuery, options?: QueryOptions): QueryWithHelpers; - deleteOne(filter: FilterQuery): QueryWithHelpers; - deleteOne(): QueryWithHelpers; + deleteOne( + filter?: FilterQuery, + options?: QueryOptions + ): QueryWithHelpers; + deleteOne(filter: FilterQuery): QueryWithHelpers< + any, + DocType, + THelpers, + RawDocType, + 'deleteOne' + >; + deleteOne(): QueryWithHelpers; /** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */ - distinct(field: string, filter?: FilterQuery): QueryWithHelpers, DocType, THelpers, RawDocType>; + distinct( + field: string, + filter?: FilterQuery + ): QueryWithHelpers, DocType, THelpers, RawDocType, 'distinct'>; /** Specifies a `$elemMatch` query condition. When called with one argument, the most recent path passed to `where()` is used. */ elemMatch(path: K, val: any): this; @@ -289,7 +324,13 @@ declare module 'mongoose' { equals(val: any): this; /** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */ - estimatedDocumentCount(options?: QueryOptions): QueryWithHelpers; + estimatedDocumentCount(options?: QueryOptions): QueryWithHelpers< + number, + DocType, + THelpers, + RawDocType, + 'estimatedDocumentCount' + >; /** Specifies a `$exists` query condition. When called with one argument, the most recent path passed to `where()` is used. */ exists(path: K, val: boolean): this; @@ -308,81 +349,99 @@ declare module 'mongoose' { filter: FilterQuery, projection?: ProjectionType | null, options?: QueryOptions | null - ): QueryWithHelpers, DocType, THelpers, RawDocType>; + ): QueryWithHelpers, DocType, THelpers, RawDocType, 'find'>; find( filter: FilterQuery, projection?: ProjectionType | null - ): QueryWithHelpers, DocType, THelpers, RawDocType>; + ): QueryWithHelpers, DocType, THelpers, RawDocType, 'find'>; find( filter: FilterQuery - ): QueryWithHelpers, DocType, THelpers, RawDocType>; - find(): QueryWithHelpers, DocType, THelpers, RawDocType>; + ): QueryWithHelpers, DocType, THelpers, RawDocType, 'find'>; + find(): QueryWithHelpers, DocType, THelpers, RawDocType, 'find'>; /** Declares the query a findOne operation. When executed, returns the first found document. */ findOne( filter?: FilterQuery, projection?: ProjectionType | null, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; findOne( filter?: FilterQuery, projection?: ProjectionType | null - ): QueryWithHelpers; + ): QueryWithHelpers; findOne( filter?: FilterQuery - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */ findOneAndDelete( filter?: FilterQuery, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findOneAndRemove` query: atomically finds the given document and deletes it. */ findOneAndRemove( filter?: FilterQuery, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */ findOneAndUpdate( filter: FilterQuery, update: UpdateQuery, options: QueryOptions & { rawResult: true } - ): QueryWithHelpers, DocType, THelpers, RawDocType>; + ): QueryWithHelpers, DocType, THelpers, RawDocType, 'findOneAndUpdate'>; findOneAndUpdate( filter: FilterQuery, update: UpdateQuery, options: QueryOptions & { upsert: true } & ReturnsNewDoc - ): QueryWithHelpers; + ): QueryWithHelpers; findOneAndUpdate( filter?: FilterQuery, update?: UpdateQuery, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Declares the query a findById operation. When executed, returns the document with the given `_id`. */ findById( id: mongodb.ObjectId | any, projection?: ProjectionType | null, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; findById( id: mongodb.ObjectId | any, projection?: ProjectionType | null - ): QueryWithHelpers; + ): QueryWithHelpers; findById( id: mongodb.ObjectId | any - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */ - findByIdAndDelete(id?: mongodb.ObjectId | any, options?: QueryOptions | null): QueryWithHelpers; + findByIdAndDelete( + id?: mongodb.ObjectId | any, + options?: QueryOptions | null + ): QueryWithHelpers; /** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */ - findByIdAndUpdate(id: mongodb.ObjectId | any, update: UpdateQuery, options: QueryOptions & { rawResult: true }): QueryWithHelpers; - findByIdAndUpdate(id: mongodb.ObjectId | any, update: UpdateQuery, options: QueryOptions & { upsert: true } & ReturnsNewDoc): QueryWithHelpers; - findByIdAndUpdate(id?: mongodb.ObjectId | any, update?: UpdateQuery, options?: QueryOptions | null): QueryWithHelpers; - findByIdAndUpdate(id: mongodb.ObjectId | any, update: UpdateQuery): QueryWithHelpers; + findByIdAndUpdate( + id: mongodb.ObjectId | any, + update: UpdateQuery, + options: QueryOptions & { rawResult: true } + ): QueryWithHelpers; + findByIdAndUpdate( + id: mongodb.ObjectId | any, + update: UpdateQuery, + options: QueryOptions & { upsert: true } & ReturnsNewDoc + ): QueryWithHelpers; + findByIdAndUpdate( + id?: mongodb.ObjectId | any, + update?: UpdateQuery, + options?: QueryOptions | null + ): QueryWithHelpers; + findByIdAndUpdate( + id: mongodb.ObjectId | any, + update: UpdateQuery + ): QueryWithHelpers; /** Specifies a `$geometry` condition */ geometry(object: { type: string, coordinates: any[] }): this; @@ -431,7 +490,9 @@ declare module 'mongoose' { j(val: boolean | null): this; /** Sets the lean option. */ - lean>[] : Require_id>>(val?: boolean | any): QueryWithHelpers; + lean>[] : Require_id>) : ResultType>( + val?: boolean | any + ): QueryWithHelpers; /** Specifies the maximum number of documents the query will return. */ limit(val: number): this; @@ -448,7 +509,7 @@ declare module 'mongoose' { * Runs a function `fn` and treats the return value of `fn` as the new value * for the query to resolve to. */ - transform(fn: (doc: ResultType) => MappedType): QueryWithHelpers; + transform(fn: (doc: ResultType) => MappedType): QueryWithHelpers; /** Specifies an `$maxDistance` query condition. When called with one argument, the most recent path passed to `where()` is used. */ maxDistance(path: string, val: number): this; @@ -500,15 +561,34 @@ declare module 'mongoose' { * This is handy for integrating with async/await, because `orFail()` saves you * an extra `if` statement to check if no document was found. */ - orFail(err?: NativeError | (() => NativeError)): QueryWithHelpers, DocType, THelpers, RawDocType>; + orFail(err?: NativeError | (() => NativeError)): QueryWithHelpers, DocType, THelpers, RawDocType, QueryOp>; /** Specifies a `$polygon` condition */ polygon(path: string, ...coordinatePairs: number[][]): this; polygon(...coordinatePairs: number[][]): this; /** Specifies paths which should be populated with other documents. */ - populate(path: string | string[], select?: string | any, model?: string | Model, match?: any): QueryWithHelpers, DocType, THelpers, UnpackedIntersection>; - populate(options: PopulateOptions | (PopulateOptions | string)[]): QueryWithHelpers, DocType, THelpers, UnpackedIntersection>; + populate( + path: string | string[], + select?: string | any, + model?: string | Model, + match?: any + ): QueryWithHelpers< + UnpackedIntersection, + DocType, + THelpers, + UnpackedIntersection, + QueryOp + >; + populate( + options: PopulateOptions | (PopulateOptions | string)[] + ): QueryWithHelpers< + UnpackedIntersection, + DocType, + THelpers, + UnpackedIntersection, + QueryOp + >; /** Get/set the current projection (AKA fields). Pass `null` to remove the current projection. */ projection(fields?: ProjectionFields | string): ProjectionFields; @@ -530,7 +610,11 @@ declare module 'mongoose' { * `update()`, except MongoDB will replace the existing document and will * not accept any [atomic](https://www.mongodb.com/docs/manual/tutorial/model-data-for-atomic-operations/#pattern) operators (`$set`, etc.) */ - replaceOne(filter?: FilterQuery, replacement?: DocType | AnyObject, options?: QueryOptions | null): QueryWithHelpers; + replaceOne( + filter?: FilterQuery, + replacement?: DocType | AnyObject, + options?: QueryOptions | null + ): QueryWithHelpers; /** Specifies which document fields to include or exclude (also known as the query "projection") */ select(arg: string | string[] | Record): this; @@ -601,13 +685,21 @@ declare module 'mongoose' { * `filter` (as opposed to just the first one) regardless of the value of * the `multi` option. */ - updateMany(filter?: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: QueryOptions | null): QueryWithHelpers; + updateMany( + filter?: FilterQuery, + update?: UpdateQuery | UpdateWithAggregationPipeline, + options?: QueryOptions | null + ): QueryWithHelpers; /** * Declare and/or execute this query as an updateOne() operation. Same as * `update()`, except it does not support the `multi` or `overwrite` options. */ - updateOne(filter?: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: QueryOptions | null): QueryWithHelpers; + updateOne( + filter?: FilterQuery, + update?: UpdateQuery | UpdateWithAggregationPipeline, + options?: QueryOptions | null + ): QueryWithHelpers; /** * Sets the specified number of `mongod` servers, or tag set of `mongod` servers,