mysql - Sequelize 获取查询的所有数据而不执行我的条件 'where'

标签 mysql node.js sequelize.js

我尝试使用以下 Sequelize 代码从数据库 mysql 获取一些值:

subSector
        .sync()
        .then(() => subSector.findAll({
            Where: {
                Enterprise_Evaluation_ID: 2
            }
        }))
        .then(result => {
            console.log(result)
        })
        .catch(error => {
           console.log(error)
        })
}

问题是sequelize获取表的所有值,而不仅仅是条件where的数据。

有什么想法吗?

我们最近更改了AWS中的服务器项目(将elasticbeanstalk更改为其他实例eb)

最佳答案

我能找到的唯一问题是,Where应该是小写,如where

subSector.findAll({
    Where: {
        Enterprise_Evaluation_ID: 2
    }
})

将其更改为:

subSector.findAll({
    where: { // <--------- HERE
        Enterprise_Evaluation_ID: 2 // <--------- Also make sure the field name is proper
    }
})

关于mysql - Sequelize 获取查询的所有数据而不执行我的条件 'where',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52529023/

相关文章:

javascript - 如何使用 Firebase Cloud Messaging 向多个设备发送推送通知

javascript - 如何获取 casper.js http.status 代码?

node.js - 当没有任何更改时,Sequelize 关联/模型突然无法识别,模糊错误无法读取未定义的属性 'field'

node.js - 如何处理需求循环?

php - 语义 Ui 自动完成

MySQL GROUP BY 和 ORDER BY 命令

mysql - SQL - 计入多列

C# MySQL 声称字段太长

node.js - Node : path must be a string

mysql - Sequelize : require at least one association