můžete vyzkoušet tento balíček https://www.npmjs.com/package/mongoose- ts-ua
@setSchema()
class User1 extends User {
@prop()
name?: string;
@setMethod
method1() {
console.log('method1, user1');
}
}
@setSchema()
class User2 extends User {
@prop({ required: true })
name?: string;
@prop()
child: User1;
}
export const User2Model = getModelForClass<User2, typeof User2>(User2);
použití
let u2 = new User2Model({ child: { name: 'u1' } });