javascript - MySQL连接表时出现: Get all columns except one,

标签 javascript node.js join sequelize.js

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

我希望 password 属性/列出现在 Promise 响应中。这是行不通的,因为我正在打电话
属性:{排除:['密码'] }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 })
})

提前致谢

最佳答案

这是我的解决方案:

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

关于javascript - MySQL连接表时出现: Get all columns except one,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56061984/

相关文章:

javascript - 无法在普通 javascript 中从 xml 加载数据

node.js - 在node.js中使用npm调试包登录时如何显示时间戳?

MySQL查看多个表重复项

javascript - 在 Internet Explorer 中向选择添加选项不起作用

javascript - 获取对象内部的函数名称

javascript - Slickgrid - 替换 AJAX 源中的所有网格数据

mysql - 使用 Node 和 Mysql

node.js - Node Vue 需要在组件中使用的库

PostgreSQL - 优化连接比较距离的纬度和经度

Python或bash : Merging two csv files based on several matching field values,格式化,输出CSV