-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
ts def of updateOne&findOneAndUpdate returns FlattenMap instead of UpdateWriteOpResult, when lean() is used #13382
Comments
Okay looking close at this, this is only happening on two places in this file, but works on 23 more. |
Okay, problem 1 solved, another one popped up, now .lean() cannot be removed because I'm using findOneAndUpdate() it says again FlattenMap is returned, which does not have a lastErrorObject and value, it should correctly return ModifyResult instead. Update 1: Thinking about rawResult.. ppbl this infer that no mongoose magic is happen anyway, right? Removing lean() would solve my problem again.. |
types: make `lean()` not clobber result type for `updateOne()`, etc.
Prerequisites
Mongoose version
7.1.0
Node.js version
16.20
MongoDB server version
5.x
Typescript version (if applicable)
4.9.5
Description
I tried upgrading to mongoose 7.x, but now I'm stuck with some typescript issues.
somehow updateOne returns a FlattenMap and not the ResultType defined in updateOne:
I would expect a UpdateWriteOpResult here.
Steps to Reproduce
my UserModel is defined as
just run updateOne on it and check the return type.
Expected Behavior
typescript should correctly return the UpdateWriteOpResult
The text was updated successfully, but these errors were encountered: