续集如何查找具有多个where子句和时间戳的行>现在() [英] Sequelize how to find rows with multiple where clauses and timestamp > NOW()

查看:9
本文介绍了续集如何查找具有多个where子句和时间戳的行>现在()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 Sequelize 做到这一点?

How do I do this with Sequelize?

SELECT FROM sessions WHERE user_id = ? AND token = ? AND expires > NOW()

这是我想要做的(假设 Session 是一个 Sequelize 模型):

Here's what I'm trying to do (assume Session is a Sequelize model):

Session.find({
    where: {
        user_id: someNumber,
        token: someString,
        //expires > NOW() (how do I do this?)
    }
}).on('success', function (s) { /* things and stuff */ });

谢谢!

推荐答案

你有没有尝试在sequelize中使用finders的数组表示法?

did you try to use the array notation of finders in sequelize?

Session.find({
  where: ['user_id=? and token=? and expires > NOW()', someNumber, someString]
}).on('success', function (s) { /* things and stuff */ });

您可以查看此页面:http://sequelizejs.com/?active=find-objects#find-对象

希望这可行.否则这是一个错误:D

Hope this works. Otherwise it's a bug :D

这篇关于续集如何查找具有多个where子句和时间戳的行>现在()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆