Skip to content

Commit

Permalink
fix(types): support findOneAndReplace with rawResult
Browse files Browse the repository at this point in the history
Both findOneAndReplace and findOneAndUpdate support the rawResult
option, which changes the return type to include more information from
the MongoDB driver. Add an overload for findOneAndReplace to support
rawResult in a way similar to findOneAndUpdate.
  • Loading branch information
lantw44 committed Jul 7, 2022
1 parent a1d88e5 commit c423f65
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions types/models.d.ts
Expand Up @@ -351,6 +351,7 @@ declare module 'mongoose' {
findOneAndRemove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;

/** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, replacement: T | AnyObject, options: QueryOptions<T> & { rawResult: true }, callback?: (err: CallbackError, doc: any, res: any) => void): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, T>;
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, replacement: T | AnyObject, options: QueryOptions<T> & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: ResultDoc, res: any) => void): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, replacement?: T | AnyObject, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;

Expand Down

0 comments on commit c423f65

Please sign in to comment.