【发布时间】:2021-01-16 08:10:04
【问题描述】:
我正在尝试在 Sequelize 中执行此查询,但出现错误
查询
LineItem.findAll(
{
attributes: [
"orderId",
[fn("sum", col("quantity")), "quantity"]
],
include: [{
model: Order,
as: "lineItems",
attributes: ["invoiceId"]
}],
group: ["orderId"],
raw: true
});
错误
column \"lineItems.invoice_id\" must appear in the GROUP BY clause or be used in an aggregate function
【问题讨论】:
-
您能否将相关模型添加到问题中?
标签: node.js typescript postgresql sequelize.js