【问题标题】:Node.js Sequelize findAll() column of included table modelNode.js Sequelize findAll() 包含的表模型的列
【发布时间】:2018-06-23 11:58:04
【问题描述】:

我正在尝试在两个表之间的合并表中搜索以下条件。

它应该收集和返回有买家'alex'或卖家'alex'的记录。 买方存在于Chat 表中,卖方存在于Market 表中,如下所示。但是,我无法让它工作。欢迎任何想法。

Chat.findAll({
        where: {
           buyer: 'alex',
               seller: 'alex'

          },
        include: [{
          model: Market,
          required: true
         }]
      })

【问题讨论】:

    标签: sql node.js sequelize.js


    【解决方案1】:

    seller 必须在 Market 内部

    Chat.findAll({
            where: {
               buyer: 'alex',
              },
            include: [{
              model: Market,
              required: true,
              where: {
                seller: 'alex'
              }
            }]
          })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-11
      • 1970-01-01
      • 2022-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-28
      相关资源
      最近更新 更多