请帮忙
我如何实现一个请求“SELECT EXISTS(SELECT 1 FROM Followers WHERE follower_id = 100);”通过 Sequelize 并将结果显示在单独的字段中?
像这样的东西
await Followers.findAll({
where: { user_id: userId },
include: [
{
model: Followers,
as: 'isSubscribed',
...
},
},
]
最佳答案
做类似的事情
let followersCount = Followers.count({ where: {follower_id: 100} })
if(followersCount > 0){
//EXISTS, Do Something
}
else{
//Does not exist
}
关于node.js - Sequelize,检查行是否存在并返回 bool 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61326839/