Answer the question
In order to leave comments, you need to log in
How to search where nested array elements should have a margin?
There is a homework plan:
const schema = new Schema({
dateAssign: { type: Date, default: Date.now, index: true },
teacher: { type: Schema.ObjectId, ref: 'user', index: true },
lesson: { type: Schema.ObjectId, ref: 'lesson', index: true },
exercises: [
{ type: Schema.ObjectId, ref: 'exercise' },
],
});
mongoose.model('homework', schema)
const schema = new Schema({
block: { type: Schema.ObjectId, ref: 'lessonblock', index: true },
variant: { type: Schema.ObjectId, ref: 'variant', index: true },
result: { type: Schema.ObjectId, ref: 'exerciseresult', index: true },
variables: { type: Schema.Types.Mixed, default: {} },
start_at: { type: Date },
lock: { type: Boolean, default: false, index: true },
});
mongoose.model('exercise', schema);
const HWs = await Homework.find({ teacher, 'exercises.lock': true }, null, { sort: { dateAssign: -1 }, limit: 20 })
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question