我是使用Sequelize和Node.js的新手,但我在代码中的日期比较有问题。
User.findOne({ where: {
resetToken: passwordToken,
resetTokenExpiration: { $gt: Date.now() },
id: userId
}})当我运行它并检查日志时,查询是:
SELECT `id`, `password`, `email`, `resetToken`, `resetTokenExpiration`, `createdAt`, `updatedAt` FROM `users` AS `user` WHERE `user`.`resetToken` = 'f5779192069c3f1c3d8aae3019cf6172e83d9f07b3741a50caedf793dc3bb43c' AND `user`.`resetTokenExpiration` = '2019-11-19 06:00:00' LIMIT 1;为什么不使用resetTokenExpiration > date,而使用resetTokenExpiration = date?
谢谢
发布于 2019-11-20 10:54:06
您需要指定正确的范围operators,在本例中为[Op.gt]。
User.findOne({ where: {
resetToken: passwordToken,
resetTokenExpiration: { [Op.gt]: Date.now() }
id: userId
}})https://stackoverflow.com/questions/58944100
复制相似问题