我有两种类型的学期第一种是可信的,另一种是全部。这两种类型都有插入多个课程的课程数组。我想做一个逻辑,当服务器接收到记录获取请求时。在这里,它检查学期类型是否可信,然后在将数据发送到客户端之前执行一些条件。
条件是。
检查完学期类型后。
普莱松
数组输入
用户架构
. 当用户下次登录时,服务器将匹配
第一学期的要素和课程以及下两节课的发送通过的课程。
这是记录获取请求
server.get('/load-record', (req, res, next) => {
Record.find({})
.populate({
path: 'semesters', populate: {
path: 'lessons',
options: {
// limit: 2
}
}
})
.populate({ path: 'events' })
.exec((err, data) => {
if (err) throw err;
console.log(data[0].semesters)
res.send({ status: true, loadedData: data })
})
})
const userSchema = mongoose.Schema({
username: { type: String, required: true },
city: { type: String, required: true },
password: { type: String, required: true },
status: { type: String, required: true },
imagePath: { type: String },
date: { type: Date, default: Date.now },
lastLoggedAt: { type: Date },
Jlesson: [{
type: mongoose.SchemaTypes.ObjectId,
ref: 'JLesson'
}],
Plesson: [{ type: Object }]
})