我有两个Schema定义如下:
var WorksnapsTimeEntry = BaseSchema.extend({
student: {
type: Schema.ObjectId,
ref: 'Student'
},
timeEntries: {
type: Object
}
});
var StudentSchema = BaseSchema.extend({
firstName: {
type: String,
trim: true,
default: ''
// validate: [validateLocalStrategyProperty, 'Please fill in your first name']
},
lastName: {
type: String,
trim: true,
default: ''
// validate: [validateLocalStrategyProperty, 'Please fill in your last name']
},
displayName: {
type: String,
trim: true
},
municipality: {
type: String
}
});
Run Code Online (Sandbox Code Playgroud)
我想循环通过每个学生并显示它的时间条目.到目前为止,我有这个代码,显然不对,因为我还不知道如何加入WorksnapTimeEntry模式表.
Student.find({ status: 'student' })
.populate('student')
.exec(function (err, students) …Run Code Online (Sandbox Code Playgroud)