Skip to content
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
@Meir017

Description

@Meir017

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions