开发者

Does Mongoid have Map/Reduce?

I am using Ruby code to calculate sum from the array returned by M开发者_Go百科ongoid.

But maybe using Map/Reduce can be faster, except I don't see any docs for Map Reduce on mongoid.org and Google for

map reduce site:mongoid.org

doesn't give any result either. (or using MapReduce or Map/Reduce)

There are docs on MongoDB's site

map reduce site:mongodb.org

but need to use Map Reduce with Mongoid as well.


You can use map reduce with Mongoid just as you could through the Ruby driver directly:

# Post is a Mongoid model...
Post.collection.map_reduce(map_function, reduce_function, options)

For some examples of doing map reduce in the Ruby driver, see this blog post by Kyle Banker (maintainer of the Ruby MongoDB driver).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜