javascript - MySQL:在加入表时获取除一列之外的所有列
问题描述
我如何获取已加入用户表中除一列之外的所有列。
我希望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 })
})
提前致谢
解决方案
那是我的解决方案:
DBTweet.findAll({ include: [{ model: DBUser, attributes: { exclude: ['password'] } }, DBComment]})
推荐阅读
- ios - 设备解锁后在 iOS 上使用 PWA 进行意外缩放
- vba - 使 VBA 窗体出现在 windows 任务栏中
- javascript - 回调和异步
- amazon-web-services - 什么是 AWS Aurora Serverless 扩展时间?
- python - Firebase.post 在我的程序中不起作用
- node.js - Node.js:使用“>”标志生成回显进程
- r - 如何在 R 中自定义情节标题?
- java - 如何使用 mockito 抛出 HttpClientErrorException.Unauthorized 错误
- swift - (Swift) 如何找到调试控制台上显示的特定实例?
- excel - 使 VBA udf 与数组公式兼容