I have issue where using model query.
if I want to compare two dates for example, one found in database and other is today's date.
I wrote like this.
model.findAll({
where:{
startDate:{
[Op.gt]:now Date().toISOString(),
}
}
})
is this a good way to compare??
Try this way:
const { Op } = require('sequelize'); // "npm i sequelize"
const moment = require('moment'); // "npm i moment"
model.findAll({
where: {
startDate: {
// $gt: moment().toDate(), // Sequelize version < 5
[Op.gt]: moment().toDate(), // Sequelize version 5
}
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.