Closed Angusross111 closed 1 year ago
hi @Angusross111
You will not need to use it this way:
const plannerTask = await PlannerTask.findById<TaskType>(taskID);
You only need to provide:
const PlannerTask = model<TaskType>("PlannerTask", {
id: { type: String, required: true },
status: { type: String, required: true },
});
Right now it's not working, the fix will be included in the next release.
@Angusross111, Thank you for your feedback, we appreciate it so much.
If you have any ideas, suggestions, or feature requests feel free to create a ticket.
Thank you so much, happy coding!
Hi @Angusross111
These changes were released in version 2.3.2
What is the best way to work with Typescript with this library? I want to pass a type to the model creation, and then would expect any documents I am retrieving in the code would have the inferred types? Is that possible? currently I just get
any
as the type for plannerTask when i hover over it:Do I need to pass the type to
findById
each time?Is there also an option to not have
findById
throw an error if the document doesnt exist and just returnundefined