This one is not working with 0 result found:
user.updateMany(
{
status: { $in: ["registered", "applied"] },
createdAt: { $lt: { $subtract: [new Date(), 1000 * 3600 * 24 * 7] } }
},
{
$set: { status: "rejected" }
}
)
This one is working:
user.updateMany(
{
status: { $in: ["registered", "applied"] },
createdAt: { $lt: new Date("08/11/2022") }
},
{
$set: { status: "rejected" }
}
)
What is the issue? Is $subtract in find() the reason for not working?