我遇到了多态模型
interface IEvent {
title: string;
}
class SubscribeEvent implements IEvent {
@prop()
title: string;
@prop({ref: User})
user: IUser;
}
class NewsEvent implements IEvent {
@prop()
title: string;
@prop({ref: Post})
post: IPost;
@prop({ref: User})
user: IUser;
}
class OrderEvent implements IEvent {
@prop()
title: string;
@prop({ref: Order})
order: IOrder;
}
现在,我创建了一个typegoose模型:
class Card extends Typegoose {
@prop()
name: string;
@prop()
events: IEvent[];
}
如何正确映射并提取带有填充引用的Card
实例?