Sequelize,找到两个字段(一个是日期,另一个是小时数)的总和比现在大的地方
Sequelize, find where sum of two fields (one is date and another is number of hours) is bigger then Now
我有一个 table:
createdOn: DateTime,
alarmDeadline: SmallInt
我需要找到 (createdOn
+ alarmDeadline
> new Date()
)
的所有记录
换句话说:find all records where date created from adding date and hours are bigger then Now
).
我需要使用 Sequelize
来实现 MySQL
。
有什么帮助吗? :-)
使用Sequelize.literal
:
const foudnRecrods = await Model.findAll({
where: Sequelize.where(Sequelize.literal('DATE_ADD(createdOn,INTERVAL alarmDeadline HOUR'), '>', new Date())
});
我有一个 table:
createdOn: DateTime,
alarmDeadline: SmallInt
我需要找到 (createdOn
+ alarmDeadline
> new Date()
)
的所有记录
换句话说:find all records where date created from adding date and hours are bigger then Now
).
我需要使用 Sequelize
来实现 MySQL
。
有什么帮助吗? :-)
使用Sequelize.literal
:
const foudnRecrods = await Model.findAll({
where: Sequelize.where(Sequelize.literal('DATE_ADD(createdOn,INTERVAL alarmDeadline HOUR'), '>', new Date())
});