when you use async/await don't use callback and use try/catch in async/await approach
so you can do like this
try {
let data = await studentModel.find({});
students = data.map((d) => {
return new InterviewQuestion(d["roll_no"], d["name"]);
});
} catch (err) {
throw err;
}
try {
let data = await studentModel.find({ sClass: sClass });
students = data.map((d) => {
return new InterviewQuestion(d["roll_no"], d["name"]);
});
} catch (err) {
throw err;
}
this query is correctly
await studentModel.find({ sClass: sClass })
also you can try this :
await studentModel.find({ sClass})
your issue from another thing, because I tested the queries every things is OK
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…