Reputation: 23
**I want to delete multiple delete row in my sql which are createdBy is older than ane week **
Model.destroy({ where: { createdBy : date.Now < date.Now + 604800000}})
Can I do this from above code..?
Upvotes: 0
Views: 2482
Reputation: 23
Finally found it:
var orders = await db.order.destroy({
where: {
createdAt: {
[Op.lte] : (new Date() - 7 * 24 * 60 * 60 * 1000 )
}
}
})
Its working properly.
Upvotes: 1
Reputation: 1600
Try with this
Model.findAll({
where: {
createdBy: {
$lte: moment().subtract(7, 'days').toDate()
}
}
})
Upvotes: 0