mongoose自引用不起作用呢? - CNode技术社区

mongoose自引用不起作用呢?
发布于 9 年前 作者 suntopo 4433 次浏览 来自 问答
const ClazzSchema = new Schema({
 name: String,//班级名称,初一二班
 school: {
 type: ObjectId,
 ref: 'School'
 },//学校字段做冗余,方便查询
 virtual: Boolean,//是否为虚拟班级
 type: Number,//1理科,2文科,3艺体
 upgrade: {
 type: ObjectId,
 ref: 'Clazz'
 },//升级方向
 subClazz: {
 type: String,
 ref: 'Clazz'
 },//当前绑定的虚拟绑架
 parentClazz: {
 type: ObjectId,
 ref: 'Clazz'
 },//绑定的实体班级,虚拟班级失效后,该字段不删除
 grade: {
 type: ObjectId,
 ref: 'Grade'
 },
 status: Boolean,
 createdAt: Date,
 updatedAt: Date
});

模型设计如上,通过clazz,在populate(‘subClazz’),都没有发射查询语句,google之有说type换成string或是this的,但是我都没有试成功

回到顶部

AltStyle によって変換されたページ (->オリジナル) /