-
-
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
Export EnforceDocument<>
from TypeScript types, rename it to something more user-friendly
#10843
Comments
Add interface User {
_id: Types.ObjectId;
name: string;
email: string;
avatar?: string;
} |
How does adding Also, if you add User.create({
_id: , new Types.ObjectId() // this is required
username: "Dumbledore",
email: "dumbledore@hogwarts.com,
avatar: "<url>"
}) |
I am guessing the utility type is the way to go, since methods like .save(), .remove(), etc are missing as well. |
The utility type could work. Perhaps exporting Mongoose's internal Line 722 in 233d474
|
EnforceDocument does seem to do what I want. Should the return types for find, findAll(), etc then return a EnforceDocument? |
I think this is somewhat related to #10837 |
@Duchynko it is defiantly related |
@Bene-Graham |
EnforceDocument<>
from TypeScript types, rename it to something more user-friendly
I think this will solve #10837 as well 👍🏼 |
If we take a slightly modified version of: https://mongoosejs.com/docs/typescript.html
the return type from findOne is
that seems very verbose for putting in the function signature each time I want to reference it.
I also could not find a utility type build into the type definitions. Should we create our own type to wrap this up
or add _id to the User interface?
I am wondering what is the best practice?
Also curious what DocumentDefinition is supposed to be used for?
The text was updated successfully, but these errors were encountered: