代码之家  ›  专栏  ›  技术社区  ›  Hernan Humaña

sequelize获取查询的所有数据,而不执行我的条件“where”

  •  0
  • Hernan Humaña  · 技术社区  · 6 年前

    我试图从数据库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)

    1 回复  |  直到 6 年前
        1
  •  2
  •   Vivek Doshi    6 年前

    我能找到的唯一问题是, 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
        }
    })