I am working on calculating expiry date for each assignment submission date.
I have schema as following
{
_id: "A01",
name: "History",
startDate: "2021-08-26T21:00:00.000Z",
endDate: "2021-09-29T21:00:00.000Z"
}
It is a trivial example of a document, and I am using aggregation pipeline like the following
{
$lookup: { // }
},
{
$addFields: {
status: { $cond: { if: new Date.getnow() > $startDate && new Date.getnow() < $endDate, then: "Active", else: "Expired" } }
}
}
But I have doubts about using such logic, is there any way to achieve using above logic conforming to MongoDB Date query?