【问题标题】:MySQL: Get all columns except one, when Joining TableMySQL:在加入表时获取除一列之外的所有列
【发布时间】:2019-09-27 10:35:26
【问题描述】:

如何获取已加入用户表中除一列之外的所有列。

我希望password 属性/列出现在 Promise 响应中。这不起作用,因为我正在调用
attributes: { exclude: ['password'] }DBTweet 没有属性密码。加入的表DBUser 有这个。

这是我当前的代码。我正在使用 Sequelize ORM

DBTweet.findAll({ include: [DBUser, DBComment], attributes: { exclude: ['password'] }})
.then(tweets => {
    res.status(200).json(tweets)
})
.catch(err => {
    printC(err)
    res.status(500).json({ error: err })
})

提前致谢

【问题讨论】:

    标签: javascript node.js join sequelize.js


    【解决方案1】:

    这是我的解决方案:

    DBTweet.findAll({ include: [{ model: DBUser, attributes: { exclude: ['password'] } }, DBComment]})
    

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 2021-01-11
      • 2019-10-30
      • 2015-08-21
      • 1970-01-01
      • 2018-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多