This repository was archived by the owner on Nov 16, 2023. It is now read-only.
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Use mongoose model statics object to add method #101
Open
Description
by adding static methods to mongoose's schema object it will show how to take advantage of the mongoose.model
function even more.
using the function:
function model<T extends Document, U extends Model<T>>
this would require us to create a static method and another type
export type UserSchema = mongoose.Model<UserModel> & {
someStaticMethod: (arg1: string) => void;
}
and then at the end:
const User = mongoose.model<UserModel, UserSchema>("User", userSchema);
Metadata
Metadata
Assignees
Labels
No labels