Hello @Anurag_Sharma1,
Your condition will match any element from quiz array from a single document. For example, it might match the $gt condition with the first element and the $lt condition with another element.
You can use the $elemMatch operator to match both conditions for a single element in the quiz array. If any of the elements match then it will result document.
db.student_quiz.find(
{
quiz: {
$elemMatch: {
updated_at: {
$gt: ISODate("2024-06-22T18:30:00.000Z"),
$lt: ISODate("2024-06-23T18:30:00.000Z")
}
}
}
}
)
3 Likes