【发布时间】:2019-03-27 02:51:39
【问题描述】:
通过sequelize查询时:
where["tenant_id"] = tenant_id;
where[datecheck] = {
$gte: from,
$lte: to,
$ne: null
};
group = [ group_by + '_id' , "stage_type"];
attributes = [[group_by + '_id', 'id'], [group_by + '_name', 'group'], ["stage_type", 'type'], [ sequelize.literal('SUM(`stage_value`)'), 'count']];
Model.findAll({
attributes: attributes,
where: where,
group: group
});
我收到此错误:
数据类型错误:attr[0].indexOf 不是函数
at attributes.map.attr ( sequelize/lib/dialects/abstract/query-generator.js:1244:28)
【问题讨论】:
-
你能分享正在执行的原始查询吗?
-
SELECT
tenant_idASid,tenant_nameASgroup,stage_typeAStype, COUNT(candidate_id) AScountFROM @987645321@987645323 @ WHEREfunnel_reports.tenant_id= '10' AND (funnel_reports.stage_date>= '2018-05-31 18:30:00' ANDfunnel_reports.stage_datetenant_id,stage_type; -
我想通过 sequelize 运行该查询,但它引发了错误。我用的是sequelize 4.38.0版本
-
请edit 提问。
标签: sequelize.js