We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
6.X.X - 7.X.X
at least 16
at least 4
4.7 - latest
The return type of
const a = await Model.findById('my-id', undefined, { lean: true })
is the same as
const a = await Model.findById('my-id')
it's:
// ^? const a: (mongoose.Document<unknown, {}, { name: string; }> & { name: string; } & { _id: mongoose.Types.ObjectId; }) | null
See ts playground
The return type should be the same as
const a = await Model.findById('a').lean()
// ^? const a: (mongoose.FlattenMaps<{ name: string; }> & { _id: mongoose.Types.ObjectId; }) | null
The text was updated successfully, but these errors were encountered:
We'll investigate and see if it is reasonably possible to fix. As a workaround, use Model.findById('a').lean().
Model.findById('a').lean()
Sorry, something went wrong.
types(models+query): return lean type when passing QueryOptions wit…
lean
d348ce9
…h `lean: true` to relevant model functions like `find()` and `findOne()` Fix #13705
lean: true
find()
findOne()
Merge pull request #13721 from Automattic/vkarpov15/gh-13705
513340a
types(models+query): return `lean` type when passing QueryOptions with `lean: true` to relevant model functions like `find()` and `findOne()`
For reference, I just updated from mongoose 7.4.2 to 7.6.2 and had to change every occurrence of:
TModel.findOne<T>({}, {}, { lean: true }) TModel.find<T>({}, {}, { lean: true })
to:
TModel.findOne().lean<T>() TModel.find().lean<T[]>()
sspenst/thinky.gg@8c3c744
Successfully merging a pull request may close this issue.
Prerequisites
Mongoose version
6.X.X - 7.X.X
Node.js version
at least 16
MongoDB server version
at least 4
Typescript version (if applicable)
4.7 - latest
Description
The return type of
is the same as
it's:
// ^? const a: (mongoose.Document<unknown, {}, { name: string; }> & { name: string; } & { _id: mongoose.Types.ObjectId; }) | null
Steps to Reproduce
See ts playground
Expected Behavior
The return type should be the same as
it's:
// ^? const a: (mongoose.FlattenMaps<{ name: string; }> & { _id: mongoose.Types.ObjectId; }) | null
The text was updated successfully, but these errors were encountered: