I need to convert MySQL query below to SequelizeJS query
WHERE createdAt < now() - interval 5 hour
I got it working using Sequelize.literal
:
Model.find({
where: {
[Sequelize.Op.and]: [
Sequelize.literal(`created_at > NOW() - INTERVAL '5h'`),
],
},
logging: console.log,
})
I would love if anybody could enrich this answer by mixing in Sequelize.col()
so to automatically get the correct column name inside the literal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With