我正在使用 Typegoose v9.3.1
我需要使用Typegoose为具有非_id字段的另一个集合创建引用。
例如,我有以下型号。
类集合
export class Class {
@prop({ required: true })
public _id!: string;
@prop({ required: true })
public grade!: Source;
@prop({ autopopulate: true, ref: Student, type: String })
public students!: Ref<Student, string>[];
}
学生收藏
export class Student {
@prop({ required: true })
public rollNo!: string;
@prop({ required: true })
public name!: string;
}
从上面的示例类集合引用学生集合基于学生集合的_id字段(默认情况下)。但我需要基于rollNo字段(非 _id 字段)创建参考。
提前致谢!