代码适用于 HeidiSQL 但不适用于 sequelize (MariaDB)

code works in HeidiSQL but not sequelize (MariaDB)

如果我执行下面的序列代码sequelize

models.Venta.sum( 'total' , { 在哪里: { fechaExpedicion:{ [Op.gte]: '2018-03-31 00:00:00', [Op.lte]: '2018-03-31 23:59:59' } }, 属性:['elaboradoPor'], 群组:'elaboradoPor' , 记录:console.log }) .then(totalIva => { console.log(JSON.stringify(totalIva)) }) .catch(e=> {console.log(e)})

我只看到调查的第一个结果(有续集)。 result sequelize code

有 记录:console.log 我得到了 MariaDB 的 SQL 指令:

SELECT elaboradoPor, sum(total) AS sum FROM Venta AS Venta WHERE (Venta. fechaExpedicion >= '2018-03-31 00:00:00' AND Venta.fechaExpedicion <= '2018-03-31 23:59:59') GROUP BY elaboradoPor;

如果我执行,HeidiSQL 中的 select 会给出正确的结果。 Select HeidySQL

请问sequelize指令中缺少什么以获得最好的结果?

我改了指令,用findall()和fn来构建求和和集成附加操作。

models.Venta.findAll({
  where: {
    fechaExpedicion: {
      [Op.gte]: '2018-03-31 00:00:00',
      [Op.lte]: '2018-03-31 23:59:59'
    }
  },
  logging: console.log,
  attributes: [
            'elaboradoPor',
            [Sequelize.fn('SUM', Sequelize.col('total')), 'totalSuma'],
            [Sequelize.fn('SUM', Sequelize.col('totalIva')), 'totalIva'],
            [Sequelize.fn('SUM', Sequelize.col('saldo')), 'totalSaldo']
            ],
        group: ['elaboradoPor']
})
.then(resultados => {
  console.log(JSON.stringify(resultados))
})
.catch(e => { console.log(e) 
})

响应:sequelize final