【问题标题】:TypeError: attr[0].indexOf is not a functionTypeError: attr[0].indexOf 不是函数
【发布时间】: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_id AS id, tenant_name AS group, stage_type AS type, COUNT(candidate_id) AS count FROM @987645321@987645323 @ WHERE funnel_reports.tenant_id = '10' AND (funnel_reports.stage_date >= '2018-05-31 18:30:00' AND funnel_reports.stage_date tenant_id, stage_type;
  • 我想通过 sequelize 运行该查询,但它引发了错误。我用的是sequelize 4.38.0版本
  • edit 提问。

标签: sequelize.js


【解决方案1】:

我认为当查询中的 id 为空时会引发此错误。

【讨论】:

  • 欢迎来到 StackOverflow 并感谢您的贡献。请把我删除的部分在这里变成评论。 (你可以)
猜你喜欢
  • 2020-03-03
  • 1970-01-01
  • 2020-03-11
  • 2022-01-08
  • 2021-06-30
  • 2020-08-04
  • 2022-01-22
  • 2021-02-19
  • 1970-01-01
相关资源
最近更新 更多