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

Why does mongoose not export the DeleteResult type #14946

Closed
1 task done
chtpl opened this issue Oct 9, 2024 · 1 comment · Fixed by #14947
Closed
1 task done

Why does mongoose not export the DeleteResult type #14946

chtpl opened this issue Oct 9, 2024 · 1 comment · Fixed by #14947
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@chtpl
Copy link

chtpl commented Oct 9, 2024

Prerequisites

  • I have written a descriptive issue title

Mongoose version

8.5.2

Node.js version

22.x

MongoDB version

6.x

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

22.04

Issue

I am implementing a database deleteMany query in a NestJS repository class
I prefer declaring the return types explicitly on my methods
However when I defined Promise<DeleteResult> as return type for my method, I cannot find an exported member DeleteResult to import to my repository class file.
However, type inference shows that model.deleteMany({}).exec() returns that type from mongoose.

I wonder why this is the case as I can perfectly import UpdateWriteOpResult to check the updated documents count on update queries

@chtpl chtpl added help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary help wanted labels Oct 9, 2024
@vkarpov15
Copy link
Collaborator

You should be able to do import { DeleteResult } from 'mongodb' as a workaround, but you're right that Mongoose should export DeleteResult.

@vkarpov15 vkarpov15 added this to the 8.7.2 milestone Oct 9, 2024
@vkarpov15 vkarpov15 added typescript Types or Types-test related issue / Pull Request and removed help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary help wanted labels Oct 9, 2024
vkarpov15 added a commit that referenced this issue Oct 13, 2024
types: re-export DeleteResult and UpdateResult from MongoDB Node.js driver
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
Development

Successfully merging a pull request may close this issue.

2 participants