From e7d5c93c2bf4eb3c3065cb4c9cd27af96be10c6a Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Thu, 9 May 2024 07:12:18 -0400 Subject: [PATCH] types(model+query): pass TInstanceMethods to QueryWithHelpers so populated docs have methods Fix #14574 Re: #14441 --- test/types/populate.test.ts | 41 +++++++++++++ types/models.d.ts | 116 +++++++++++++++++++++--------------- types/query.d.ts | 111 +++++++++++++++++++--------------- 3 files changed, 173 insertions(+), 95 deletions(-) diff --git a/test/types/populate.test.ts b/test/types/populate.test.ts index fe9afa4ef84..5ac5f76e83a 100644 --- a/test/types/populate.test.ts +++ b/test/types/populate.test.ts @@ -419,3 +419,44 @@ function gh14441() { expectType(docObject.child.name); }); } + +async function gh14574() { + // Document definition + interface User { + firstName: string; + lastName: string; + friend?: Types.ObjectId; + } + + interface UserMethods { + fullName(): string; + } + + type UserModelType = mongoose.Model; + + const userSchema = new Schema( + { + firstName: String, + lastName: String, + friend: { type: Schema.Types.ObjectId, ref: 'User' } + }, + { + methods: { + fullName() { + return `${this.firstName} ${this.lastName}`; + } + } + } + ); + const userModel = model('User', userSchema); + + const UserModel = () => userModel; + + const user = await UserModel() + .findOne({ firstName: 'b' }) + .populate<{ friend: HydratedDocument }>('friend') + .orFail() + .exec(); + expectType(user.fullName()); + expectType(user.friend.fullName()); +} diff --git a/types/models.d.ts b/types/models.d.ts index 2bbb2663009..45c0d6bf93d 100644 --- a/types/models.d.ts +++ b/types/models.d.ts @@ -325,7 +325,8 @@ declare module 'mongoose' { THydratedDocumentType, TQueryHelpers, TRawDocType, - 'countDocuments' + 'countDocuments', + TInstanceMethods >; /** Creates a new document or documents */ @@ -363,7 +364,8 @@ declare module 'mongoose' { THydratedDocumentType, TQueryHelpers, TRawDocType, - 'deleteMany' + 'deleteMany', + TInstanceMethods >; deleteMany( filter: FilterQuery @@ -372,7 +374,8 @@ declare module 'mongoose' { THydratedDocumentType, TQueryHelpers, TRawDocType, - 'deleteMany' + 'deleteMany', + TInstanceMethods >; /** @@ -388,7 +391,8 @@ declare module 'mongoose' { THydratedDocumentType, TQueryHelpers, TRawDocType, - 'deleteOne' + 'deleteOne', + TInstanceMethods >; deleteOne( filter: FilterQuery @@ -397,7 +401,8 @@ declare module 'mongoose' { THydratedDocumentType, TQueryHelpers, TRawDocType, - 'deleteOne' + 'deleteOne', + TInstanceMethods >; /** @@ -426,17 +431,18 @@ declare module 'mongoose' { ResultDoc, TQueryHelpers, TRawDocType, - 'findOne' + 'findOne', + TInstanceMethods >; findById( id: any, projection?: ProjectionType | null, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; findById( id: any, projection?: ProjectionType | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Finds one document. */ findOne( @@ -448,20 +454,21 @@ declare module 'mongoose' { ResultDoc, TQueryHelpers, TRawDocType, - 'findOne' + 'findOne', + TInstanceMethods >; 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. @@ -597,7 +604,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, 'find'>; + $where(argument: string | Function): QueryWithHelpers, THydratedDocumentType, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>; /** Registered discriminators for this model. */ discriminators: { [name: string]: Model } | undefined; @@ -614,7 +621,8 @@ declare module 'mongoose' { THydratedDocumentType, TQueryHelpers, TRawDocType, - 'distinct' + 'distinct', + TInstanceMethods >; /** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */ @@ -623,7 +631,8 @@ declare module 'mongoose' { THydratedDocumentType, TQueryHelpers, TRawDocType, - 'estimatedDocumentCount' + 'estimatedDocumentCount', + TInstanceMethods >; /** @@ -637,7 +646,8 @@ declare module 'mongoose' { THydratedDocumentType, TQueryHelpers, TRawDocType, - 'findOne' + 'findOne', + TInstanceMethods >; /** Creates a `find` query: gets a list of documents that match `filter`. */ @@ -650,22 +660,23 @@ declare module 'mongoose' { ResultDoc, TQueryHelpers, TRawDocType, - 'find' + 'find', + TInstanceMethods >; find( filter: FilterQuery, projection?: ProjectionType | null | undefined, options?: QueryOptions | null | undefined - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find'>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>; find( filter: FilterQuery, projection?: ProjectionType | null | undefined - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find'>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>; find( filter: FilterQuery - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find'>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>; find( - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find'>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>; /** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */ findByIdAndDelete( @@ -676,16 +687,17 @@ declare module 'mongoose' { ResultDoc, TQueryHelpers, TRawDocType, - 'findOneAndDelete' + 'findOneAndDelete', + TInstanceMethods >; findByIdAndDelete( id: mongodb.ObjectId | any, options: QueryOptions & { includeResultMetadata: true } - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete'>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods>; findByIdAndDelete( id?: mongodb.ObjectId | any, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */ findByIdAndUpdate( @@ -697,7 +709,8 @@ declare module 'mongoose' { ResultDoc, TQueryHelpers, TRawDocType, - 'findOneAndUpdate' + 'findOneAndUpdate', + TInstanceMethods >; findByIdAndUpdate( id: mongodb.ObjectId | any, @@ -708,27 +721,28 @@ declare module 'mongoose' { ResultDoc, TQueryHelpers, TRawDocType, - 'findOneAndUpdate' + 'findOneAndUpdate', + TInstanceMethods >; findByIdAndUpdate( id: mongodb.ObjectId | any, update: UpdateQuery, options: QueryOptions & { includeResultMetadata: true } - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>; 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( @@ -739,16 +753,17 @@ declare module 'mongoose' { ResultDoc, TQueryHelpers, TRawDocType, - 'findOneAndDelete' + 'findOneAndDelete', + TInstanceMethods >; findOneAndDelete( filter: FilterQuery, options: QueryOptions & { includeResultMetadata: true } - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete'>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods>; findOneAndDelete( filter?: FilterQuery | null, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */ findOneAndReplace( @@ -760,23 +775,24 @@ declare module 'mongoose' { ResultDoc, TQueryHelpers, TRawDocType, - 'findOneAndReplace' + 'findOneAndReplace', + TInstanceMethods >; findOneAndReplace( filter: FilterQuery, replacement: TRawDocType | AnyObject, options: QueryOptions & { includeResultMetadata: true } - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace'>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace', TInstanceMethods>; 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( @@ -788,7 +804,8 @@ declare module 'mongoose' { ResultDoc, TQueryHelpers, TRawDocType, - 'findOneAndUpdate' + 'findOneAndUpdate', + TInstanceMethods >; findOneAndUpdate( filter: FilterQuery, @@ -799,30 +816,31 @@ declare module 'mongoose' { ResultDoc, TQueryHelpers, TRawDocType, - 'findOneAndUpdate' + 'findOneAndUpdate', + TInstanceMethods >; findOneAndUpdate( filter: FilterQuery, update: UpdateQuery, options: QueryOptions & { includeResultMetadata: true } - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate'>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>; findOneAndUpdate( filter: FilterQuery, update: UpdateQuery, options: QueryOptions & { upsert: true } & ReturnsNewDoc - ): QueryWithHelpers; + ): QueryWithHelpers; findOneAndUpdate( filter?: FilterQuery, update?: UpdateQuery, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */ replaceOne( filter?: FilterQuery, replacement?: TRawDocType | AnyObject, options?: (mongodb.ReplaceOptions & MongooseQueryOptions) | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Apply changes made to this model's schema after this model was compiled. */ recompileSchema(): void; @@ -835,33 +853,35 @@ declare module 'mongoose' { filter?: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions) | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */ updateOne( filter?: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions) | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Creates a Query, applies the passed conditions, and returns the Query. */ where( path: string, val?: any - ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find'>; + ): QueryWithHelpers, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>; where(obj: object): QueryWithHelpers< Array, ResultDoc, TQueryHelpers, TRawDocType, - 'find' + 'find', + TInstanceMethods >; where(): QueryWithHelpers< Array, ResultDoc, TQueryHelpers, TRawDocType, - 'find' + 'find', + TInstanceMethods >; } } diff --git a/types/query.d.ts b/types/query.d.ts index 3be8aea2259..e827ac2d76e 100644 --- a/types/query.d.ts +++ b/types/query.d.ts @@ -43,7 +43,14 @@ declare module 'mongoose' { type ProjectionFields = { [Key in keyof DocType]?: any } & Record; - type QueryWithHelpers = Query & THelpers; + type QueryWithHelpers< + ResultType, + DocType, + THelpers = {}, + RawDocType = DocType, + QueryOp = 'find', + TInstanceMethods = Record + > = Query & THelpers; type QuerySelector = { // Comparison @@ -205,19 +212,19 @@ declare module 'mongoose' { ? (ResultType extends any[] ? Require_id>[] : Require_id>) : ResultType; - type MergePopulatePaths = QueryOp extends QueryOpThatReturnsDocument + type MergePopulatePaths> = QueryOp extends QueryOpThatReturnsDocument ? ResultType extends null ? ResultType : ResultType extends (infer U)[] ? U extends Document - ? HydratedDocument, Record, TQueryHelpers>[] + ? HydratedDocument, TInstanceMethods, TQueryHelpers>[] : (MergeType)[] : ResultType extends Document - ? HydratedDocument, Record, TQueryHelpers> + ? HydratedDocument, TInstanceMethods, TQueryHelpers> : MergeType : MergeType; - class Query implements SessionOperation { + class Query> implements SessionOperation { _mongooseOptions: MongooseQueryOptions; /** @@ -235,7 +242,8 @@ declare module 'mongoose' { DocType, THelpers, RawDocType, - QueryOp + QueryOp, + TInstanceMethods >; /** Specifies an `$all` query condition. When called with one argument, the most recent path passed to `where()` is used. */ @@ -297,7 +305,7 @@ declare module 'mongoose' { 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). @@ -313,15 +321,16 @@ declare module 'mongoose' { deleteMany( filter?: FilterQuery, options?: QueryOptions - ): QueryWithHelpers; + ): QueryWithHelpers; deleteMany(filter: FilterQuery): QueryWithHelpers< any, DocType, THelpers, RawDocType, - 'deleteMany' + 'deleteMany', + TInstanceMethods >; - deleteMany(): QueryWithHelpers; + deleteMany(): QueryWithHelpers; /** * Declare and/or execute this query as a `deleteOne()` operation. Works like @@ -331,21 +340,22 @@ declare module 'mongoose' { deleteOne( filter?: FilterQuery, options?: QueryOptions - ): QueryWithHelpers; + ): QueryWithHelpers; deleteOne(filter: FilterQuery): QueryWithHelpers< any, DocType, THelpers, RawDocType, - 'deleteOne' + 'deleteOne', + TInstanceMethods >; - deleteOne(): QueryWithHelpers; + deleteOne(): QueryWithHelpers; /** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */ distinct( field: DocKey, filter?: FilterQuery - ): QueryWithHelpers : ResultType>, DocType, THelpers, RawDocType, 'distinct'>; + ): QueryWithHelpers : ResultType>, DocType, THelpers, RawDocType, 'distinct', TInstanceMethods>; /** 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; @@ -367,7 +377,8 @@ declare module 'mongoose' { DocType, THelpers, RawDocType, - 'estimatedDocumentCount' + 'estimatedDocumentCount', + TInstanceMethods >; /** Specifies a `$exists` query condition. When called with one argument, the most recent path passed to `where()` is used. */ @@ -387,29 +398,29 @@ declare module 'mongoose' { filter: FilterQuery, projection?: ProjectionType | null, options?: QueryOptions | null - ): QueryWithHelpers, DocType, THelpers, RawDocType, 'find'>; + ): QueryWithHelpers, DocType, THelpers, RawDocType, 'find', TInstanceMethods>; find( filter: FilterQuery, projection?: ProjectionType | null - ): QueryWithHelpers, DocType, THelpers, RawDocType, 'find'>; + ): QueryWithHelpers, DocType, THelpers, RawDocType, 'find', TInstanceMethods>; find( filter: FilterQuery - ): QueryWithHelpers, DocType, THelpers, RawDocType, 'find'>; - find(): QueryWithHelpers, DocType, THelpers, RawDocType, 'find'>; + ): QueryWithHelpers, DocType, THelpers, RawDocType, 'find', TInstanceMethods>; + find(): QueryWithHelpers, DocType, THelpers, RawDocType, 'find', TInstanceMethods>; /** 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( @@ -422,62 +433,62 @@ declare module 'mongoose' { filter: FilterQuery, update: UpdateQuery, options: QueryOptions & { includeResultMetadata: true } - ): QueryWithHelpers, DocType, THelpers, RawDocType, 'findOneAndUpdate'>; + ): QueryWithHelpers, DocType, THelpers, RawDocType, 'findOneAndUpdate', TInstanceMethods>; 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 & { includeResultMetadata: true } - ): QueryWithHelpers, DocType, THelpers, RawDocType, 'findOneAndDelete'>; + ): QueryWithHelpers, DocType, THelpers, RawDocType, 'findOneAndDelete', TInstanceMethods>; findByIdAndDelete( 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 & { includeResultMetadata: true } - ): QueryWithHelpers; + ): QueryWithHelpers; 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; /** Specifies a `$geometry` condition */ geometry(object: { type: string, coordinates: any[] }): this; @@ -537,7 +548,8 @@ declare module 'mongoose' { DocType, THelpers, RawDocType, - QueryOp + QueryOp, + TInstanceMethods >; /** Specifies the maximum number of documents the query will return. */ @@ -555,7 +567,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; @@ -607,7 +619,7 @@ 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, QueryOp>; + orFail(err?: NativeError | (() => NativeError)): QueryWithHelpers, DocType, THelpers, RawDocType, QueryOp, TInstanceMethods>; /** Specifies a `$polygon` condition */ polygon(path: string, ...coordinatePairs: number[][]): this; @@ -624,7 +636,8 @@ declare module 'mongoose' { DocType, THelpers, RawDocType, - QueryOp + QueryOp, + TInstanceMethods >; populate( options: PopulateOptions | (PopulateOptions | string)[] @@ -633,7 +646,8 @@ declare module 'mongoose' { DocType, THelpers, RawDocType, - QueryOp + QueryOp, + TInstanceMethods >; populate( path: string | string[], @@ -641,20 +655,22 @@ declare module 'mongoose' { model?: string | Model, match?: any ): QueryWithHelpers< - MergePopulatePaths, + MergePopulatePaths, DocType, THelpers, UnpackedIntersection, - QueryOp + QueryOp, + TInstanceMethods >; populate( options: PopulateOptions | (PopulateOptions | string)[] ): QueryWithHelpers< - MergePopulatePaths, + MergePopulatePaths, DocType, THelpers, UnpackedIntersection, - QueryOp + QueryOp, + TInstanceMethods >; /** Add pre middleware to this query instance. Doesn't affect other queries. */ @@ -687,7 +703,7 @@ declare module 'mongoose' { filter?: FilterQuery, replacement?: DocType | AnyObject, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** Specifies which document fields to include or exclude (also known as the query "projection") */ select( @@ -713,7 +729,8 @@ declare module 'mongoose' { RawDocType, RawDocTypeOverride >, - QueryOp + QueryOp, + TInstanceMethods >; /** Determines if field selection has been made. */ @@ -789,7 +806,7 @@ declare module 'mongoose' { filter?: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** * Declare and/or execute this query as an updateOne() operation. Same as @@ -799,7 +816,7 @@ declare module 'mongoose' { filter?: FilterQuery, update?: UpdateQuery | UpdateWithAggregationPipeline, options?: QueryOptions | null - ): QueryWithHelpers; + ): QueryWithHelpers; /** * Sets the specified number of `mongod` servers, or tag set of `mongod` servers,