【发布时间】:2017-04-29 08:11:09
【问题描述】:
我有如下数据
"student" : [
ObjectId("58500ea5ef914125073b040f"),
ObjectId("58500ea5ef914125073b042e")
],
我的模特,
student: [{type: Schema.ObjectId,ref: 'Student'}],
我想在这些数组中填充学生,
Classroom.findById(id).populate('student.student'){}
它不起作用,任何人都可以建议帮助。谢谢。
【问题讨论】:
-
您是否将 ref 添加到模型的架构
student:[{ type: Schema.Types.ObjectId, ref: 'Student' }] -
是的,我做到了.....
-
您能否展示您的架构代码,并确保您有适当的数据填充到数据库中。
-
请发布您的课堂架构。
-
您好发布了我的架构。
标签: node.js mongodb mongoose mongoose-populate