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

Incorrect return type for doc.findOneAndDelete() #14130

Closed
2 tasks done
asvendby opened this issue Nov 29, 2023 · 2 comments · Fixed by #14153
Closed
2 tasks done

Incorrect return type for doc.findOneAndDelete() #14130

asvendby opened this issue Nov 29, 2023 · 2 comments · Fixed by #14153
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@asvendby
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8.0.2

Node.js version

20.10.0

MongoDB server version

6.2.0

Typescript version (if applicable)

5.3.2

Description

The return type for doc.findOneAndDelete(...) is of type ModifyResult while MongoDB returns the document

Steps to Reproduce

See return type for MongoDB here and the type definition here

Expected Behavior

Expected that the return type is the document, not ModifyResult

@vkarpov15 vkarpov15 added this to the 8.0.3 milestone Nov 29, 2023
@vkarpov15 vkarpov15 added the typescript Types or Types-test related issue / Pull Request label Nov 29, 2023
@jnoggler
Copy link

can confirm this exact behaviour as well

@momenthana
Copy link

it was handled temporarily

- const session = await Session.findOneAndDelete({ sessionToken }) // return ModifyResult<SessionDocument>
+ const session = await Session.findOneAndDelete({ sessionToken }, {}) // return SessionDocument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
4 participants