0

升级到 MongoID 5 后,我收到此错误:NoMethodError: undefined method `[]' for #

代码如下所示:

result = ::Presentation::Interaction.collection.aggregate(
  [
    user_match_criterias_live(conference),
    ::Presentation::ReportGenerator::DELCOUNTRY_AGGREGATION
  ]
)
return 0 if (result.count < 1)
return result[0]["total"]

因此,聚合已经使用数组作为参数。

4

1 回答 1

0

检查结果包含什么后,我意识到它没有响应[]。但是,它确实响应 .first

代码看起来像

result = ::Presentation::Interaction.collection.aggregate(
  [
    user_match_criterias_live(conference),
    ::Presentation::ReportGenerator::DELCOUNTRY_AGGREGATION
  ]
)
return 0 if (result.count < 1)
return result.first["total"]
于 2016-09-19T08:18:33.560 回答