【发布时间】:2011-10-22 12:04:50
【问题描述】:
我正在尝试使用带有 Mongoid 的 MongoDB 在 Rails 3.1 应用程序中映射/缩小范围。
结果看起来很奇怪,所以我想知道 map_reduce 是否可以像这样应用于预作用域的集合:
current_user.tasks.for_year_and_month(year, month).collection.map_reduce(map, reduce, :out => "res")
for_year_and_month 限定给定月份的任务,但 map_reduce 的结果似乎也包括其他任务。现在我想知道我的 map/reduce 函数是否错误,或者 map/reduce 不能应用于预作用域的集合。
如果是这样,我必须在我的 emit 函数中完成所有作用域的工作,这会使事情变得更糟。我不敢相信。
有人能告诉我吗?
问候 费利克斯
【问题讨论】:
标签: ruby-on-rails mongodb mapreduce mongoid