AdithyaSK's picture
AdithyaSK HF Staff
Add files using upload-large-folder tool
811af7f verified
|
Raw History Blame Contribute Delete
1.24 kB

Fix the following issue:

ts def of updateOne&findOneAndUpdate returns FlattenMap instead of UpdateWriteOpResult, when lean() is used

Prerequisites

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

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. image

somehow updateOne returns a FlattenMap and not the ResultType defined in updateOne: image

I would expect a UpdateWriteOpResult here.

Steps to Reproduce

my UserModel is defined as

const userSchema = new Schema({...});

export interface IDBUser { .. };

const DBUserModel: Model<IDBUser> = model<IDBUser>('User', userSchema);

just run updateOne on it and check the return type.

Expected Behavior

typescript should correctly return the UpdateWriteOpResult