【问题标题】:How to get attributes of join table with sequelize findAll()如何使用 sequelize findAll() 获取连接表的属性
【发布时间】:2020-03-15 23:33:16
【问题描述】:

我想将连接表的属性与主表一起连接。 但实际发生的是,我只得到主表属性作为响应。 我也需要在响应中加入表属性

【问题讨论】:

  • 请分享您的代码。
  • 请发布您的代码。

标签: node.js sequelize.js


【解决方案1】:

你可以试试这样的

 your_table
  .findAll({
    raw: true,
    include: [
      {
        model: <your_join_table>
      }
    ],
  })
  .then(result => {
    console.table(result);
  })
  .catch(err => console.log(err));

【讨论】:

    猜你喜欢
    • 2017-02-11
    • 2019-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-18
    • 2021-06-05
    • 2021-02-19
    • 1970-01-01
    相关资源
    最近更新 更多