MongoID 5 Aggregations: NoMethodError: undefined method `[]' for Aggregation
MongoID 5 Aggregations: NoMethodError: undefined method `[]' for Aggregation
升级到 MongoID 5 后出现此错误:
NoMethodError:#
的未定义方法“[]”
代码如下:
result = ::Presentation::Interaction.collection.aggregate(
[
user_match_criterias_live(conference),
::Presentation::ReportGenerator::DELCOUNTRY_AGGREGATION
]
)
return 0 if (result.count < 1)
return result[0]["total"]
因此,聚合已经在使用数组作为参数。
查看结果包含的内容后,我意识到它没有响应 []。但是,它确实响应 .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"]
升级到 MongoID 5 后出现此错误: NoMethodError:#
的未定义方法“[]”代码如下:
result = ::Presentation::Interaction.collection.aggregate(
[
user_match_criterias_live(conference),
::Presentation::ReportGenerator::DELCOUNTRY_AGGREGATION
]
)
return 0 if (result.count < 1)
return result[0]["total"]
因此,聚合已经在使用数组作为参数。
查看结果包含的内容后,我意识到它没有响应 []。但是,它确实响应 .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"]