在where子句中使用OR时出错

时间:2015-05-20 12:13:39

标签: node.js express sequelize.js

我尝试根据文档here使用or运算符在sequelize中执行查询。

m.client_state.find({
    where: {
        validUntil: {
            $or: {
                lt: Date.now(),
                eq: null
            }
        }
    }

根据文档,这对我来说是正确的。我也尝试过$和运算符而没有使用$符号但是我总是得到这个例外。

TypeError: undefined is not a function
at Object.module.exports.QueryGenerator.whereItemQuery (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1753:45)
at /home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1609:27
at /home/grimurd/Documents/Repos/WiFi/node_modules/lodash/index.js:3159:15
at baseForOwn (/home/grimurd/Documents/Repos/WiFi/node_modules/lodash/index.js:2089:14)
at Function.<anonymous> (/home/grimurd/Documents/Repos/WiFi/node_modules/lodash/index.js:3438:16)
at Object.module.exports.QueryGenerator.whereItemsQuery (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1608:11)
at Object.module.exports.QueryGenerator.getWhereConditions (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1980:21)
at Object.module.exports.QueryGenerator.selectQuery (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1287:30)
at module.exports.QueryInterface.select (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/lib/query-interface.js:685:27)
at null.<anonymous> (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/lib/model.js:743:34)
at tryCatcher (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/node_modules/bluebird/js/main/util.js:24:31)
at Promise._settlePromiseFromHandler (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/node_modules/bluebird/js/main/promise.js:454:31)
at Promise._settlePromiseAt (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/node_modules/bluebird/js/main/promise.js:530:18)
at Async._drainQueue (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/node_modules/bluebird/js/main/async.js:182:12)
at Async._drainQueues (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/node_modules/bluebird/js/main/async.js:187:10)
at Immediate.Async.drainQueues [as _onImmediate] (/home/grimurd/Documents/Repos/WiFi/node_modules/sequelize/node_modules/bluebird/js/mai

如果我跳过$或仅使用lt或eq。

,代码工作正常

1 个答案:

答案 0 :(得分:0)

您错过了 $

$lt: Date.now(),
$eq: null