To add Where statement with date with Node Sequelize, we use operator properties.
For instance, we write
const { Op } = require("sequelize");
model.findAll({
where: {
start_datetime: {
[Op.gte]: moment().subtract(7, "days").toDate(),
},
},
});
to call findAll
to look for the entries with start_datetime
bigger than or equal to 7 days before today.
We get the date with moment().subtract(7, "days").toDate()
.