-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
TypeScript docs: query helpers, statics #10021
Comments
|
I took a closer look and for (2) we don't need another generic parameter. Just define a new interface that interface IProject extends Document {
name: string;
}
interface ProjectModel extends Model<IProject> {
myStatic(n: number): number;
}
const Project = connection.model<IProject, ProjectModel, {}>('Project', projectSchema);
// `Project` gets `myStatic()` from `ProjectModel`
Project.myStatic(42); |
I have a type:
With a usual query, I have ObjectIds array in field
|
The way I've solved it is to always populate through a function, then you can cast the the return type to the correct types.
Then it can be consumed like this:
Where listing is now of type IListing_populated It can probably be done smarter, but at least this solves it for now |
Hi there,
I've tried migrate to v.12 and have some questions.
How can I type populate?
May be I don't understand, but I couldn't set type in Model for populate query.
Can I have strong types for static methods?
Now I can see that any static method has type (...args: any[])
How can I use TQueryHelpers?
Thanks
The text was updated successfully, but these errors were encountered: