Skip to content

Commit

Permalink
Merge pull request #13367 from Automattic/vkarpov15/deleteone-ts
Browse files Browse the repository at this point in the history
types(document): correct return type for `Model.prototype.deleteOne()`: promise, not query
  • Loading branch information
vkarpov15 authored May 2, 2023
2 parents a67b7a7 + 250d160 commit 1c4e6a9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/types/document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Test = model<ITest>('Test', schema);
void async function main() {
const doc = await Test.findOne().orFail();

expectType<Query<any, TestDocument>>(doc.deleteOne());
expectType<Promise<TestDocument>>(doc.deleteOne());
}();


Expand Down
2 changes: 1 addition & 1 deletion types/document.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ declare module 'mongoose' {
db: Connection;

/** Removes this document from the db. */
deleteOne(options?: QueryOptions): QueryWithHelpers<any, this, TQueryHelpers>;
deleteOne(options?: QueryOptions): Promise<this>;

/**
* Takes a populated field and returns it to its unpopulated state. If called with
Expand Down

0 comments on commit 1c4e6a9

Please sign in to comment.