首页 > 解决方案 > Objection.js Eager 缺少 FROM 子句

问题描述

我正在对 PostGres 使用反对 js,并尝试找到礼物状态为“已关闭”的付款,但我不断收到错误消息:

缺少表的 FROM 子句条目

以下是我的查询。

const payments = await GiftPayments.query()
        .eager('gift.[detail, status]')
        .where('gift.status.name', 'Closed')
        .orderBy('gift.id');

我还尝试了如下所示的 modifyEager,突然状态字段变为空。

const payments = await GiftPayments.query()
            .eager('gift.[detail, status]')
            .modifyEager('gift', builder => 
                {builder.where('name', '=', 'Closed')
             })
            .orderBy('gift.id');

非常感谢你!

标签: javascriptsqlpostgresqlobjection.js

解决方案


似乎“gift”表不在 GiftPayments() 中,或者被别名为“gift”以外的东西。


推荐阅读