求大神, Sequelize 关联查询的时候 A表的一个字段和B表的一个字段比较的条件该怎么写?
比如我这里 A.currentIndex > B.index 要怎么写
A的 where 的 currentIndex 不知道写才对?
A表和B表
select * from A left join B on A.mesId = B.mesId where A.id = 1 and A.currentIndex > B.index
要实现的sql就是这个,下面是我的写法,但是是错的,求大神
const result = await A.findAll({
where: {id: ticketId, currentIndex: {[Op.gt]: Sequelize.literal(`Bname.index`)}}, //现在这里是不对的写法
attributes: ['id', 'mesId'],
raw: true,
logging: sqlLogger(req),
include: [
{
attributes: ['id', 'processName', 'groupName', 'groupId', 'index', 'processNo'],
model: B,
required: false,
as: 'Bname',
},
],});