Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): add parameter "options" to "Model.remove" #12258

Merged
merged 2 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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