Класс Мангуста Схема
Схема пользователя коллекции Mongoose
const UserSchema = new Schema({
firstName: {
type: String,
required: true,
},
lastName: {
type: String,
required: true,
},
gender: {
type: String,
enum: Object.keys(GenderType),
required: true,
},
});
UserSchema.methods = {
fullName(): string {
return `${this.firstName} ${this.lastName}`;
},
};
UserSchema.statics = {
someAction(): string {
return '123';
},
};
export default UserSchema;
Класс интерфейса документа
Класс интерфейса коллекции Mongoose
export interface IUser extends Document {
_id: Types.ObjectId;
firstName: string;
lastName: string;
gender: string;
fullName: () => string;
}
Как определить статические методы Мангуста в интерфейсе документа при использовании @ nestjs / mongoose?