顺序包含和使用时,在操场上重复显示相同的数据

时间:2019-04-29 15:09:35

标签: javascript graphql sequelize.js apollo

当我尝试运行序列化代码时。在包括,我做一个总和。总和是3个值。但是我的问题是输出显示相同值的3倍。

await models.Invoices.findAll({
        where: {partnerId: 1},
        raw: true,
        include: [
            {
                model: models.Corrections,
                attributes: ["invoiceId",[Sequelize.fn('sum', Sequelize.col('amount')), 'amount']],
                duplicating: true,
                group: ['Corrections.amount'],
                raw: true
            }
        ],
        group: ["invoices.id", "corrections.invoiceId", '"corrections.amount"'],
        order: [[Sequelize.col('"corrections.amount"'), 'ASC']]
    }).then(
        result => {
            console.log("result", result);

            return result;
        }
    )

>> id 3显示3次。

{
        "id": "1",
        "correctionTotal": 200
      },
      {
        "id": "3",
        "correctionTotal": 3500
      },
      {
        "id": "3",
        "correctionTotal": 3500
      },
      {
        "id": "3",
        "correctionTotal": 3500
      },
      {
        "id": "2",
        "correctionTotal": 0
      },
      {
        "id": "4",
        "correctionTotal": 0
      },

结果ID:3次显示3次。为什么这个东西显示3次。如何一次显示ID?

0 个答案:

没有答案