Skip to content

Commit

Permalink
Merge pull request #12258 from hasezoey/addTypesModelRemove
Browse files Browse the repository at this point in the history
fix(types): add parameter "options" to "Model.remove"
  • Loading branch information
AbdelrahmanHafez committed Aug 22, 2022
2 parents 1284e68 + 3a14bef commit ca5cc2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/types/models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ function gh12100() {
})();


function modelRemoveOptions() {
const cmodel = model('Test', new Schema());

cmodel.remove({}, {});
}

async function gh12286() {
interface IUser{
name: string;
Expand Down
3 changes: 3 additions & 0 deletions types/models.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ declare module 'mongoose' {
wtimeout?: number;
}

interface RemoveOptions extends SessionOption, Omit<mongodb.DeleteOptions, 'session'> {}

const Model: Model<any>;
interface Model<T, TQueryHelpers = {}, TMethodsAndOverrides = {}, TVirtuals = {}, TSchema = any> extends
NodeJS.EventEmitter,
Expand Down Expand Up @@ -392,6 +394,7 @@ declare module 'mongoose' {
): Promise<any>;

remove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: any, callback?: CallbackWithoutResult): QueryWithHelpers<any, ResultDoc, TQueryHelpers, T>;
remove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: any, options?: RemoveOptions, callback?: CallbackWithoutResult): QueryWithHelpers<any, ResultDoc, TQueryHelpers, T>;

/** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */
replaceOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
Expand Down

0 comments on commit ca5cc2c

Please sign in to comment.