我已经阅读了Sequelize文档,但找不到任何有用的信息
我想要做的是在include
中添加原始查询或自定义模型,是否可能?
model.Post.findAll({
include: [{
model: model.User,
attributes: ['fullname', 'profilepic'],
},
{
model: model.PostComments,
},
{
model: "Raw Query"
}
]
}
我想要实现的是:
Select post_id, count(*) as total_likes from post_likes group by post_id
我无法通过简单地使用include
实现这一点,所以我想要做的是从上面的查询创建一个表/模型,然后在include中使用它。
如果我在qazxsw poi中使用group,它从顶层给出group,我想仅仅为include
表应用qazxsw poi。
如果发现令人困惑或不清楚,请告诉我。
您可以使用
group
要么
post_like