我试图从表modelA中读取字段A的当前值,以在modelC中的where中进行筛选。这样可能吗?我尝试过:db.modelA.fieldA,或['modelA','fieldA']或['fieldA],但没有成功。
await db.modelA.findAll({
include: [
{
model: db.modelB,
attributes: ["fieldB"],
include: [
{
model: db.modelC,
where: { fieldC: { $lte: **db.modelA.fieldA** } },
},
],
},
],
})
[已解决]
await db.modelA.findAll({
include: [
{
model: db.modelB,
attributes: ["fieldB"],
include: [
{
model: db.modelC,
on: {
fieldC: {
$lte: { $col: "modelA.fieldA" },
},
},
},
],
},
],
})