Back

使用哪个?mongo mapper? mongoid? mongomastic?

发布时间: 2012-05-15 10:51:00

在一个新项目中使用mongodb, 选择Object mapper的时候,看到官方的推荐,我凌乱了:

Several mappers are available:

      MongoMapper from John Nunemaker
      Mongoid from Durran Jordan
      Mongomatic from Ben Myles
      MongoODM from Carlos Paramio
      MongoModel from Sam Pohlenz
      DriverAPILayer from Alexey Petrushin

搜索了一下,“哪个OM最好?”这样的问题在stackoverflow上被关闭了,不过这个文章非常有帮助:
http://stackoverflow.com/questions/1958365/mongoid-or-mongomapper

问:mongoid 还是用mongomapper

17票, Aynat答:
I have used MongoMapper for awhile but decided to migrate to MongoId. The reason is hidden issues plus arrogance towards users. I had to jump through hoops to make MongoMapper work with Cucumber (succeeded in the end) and to put a couple of patches even the project was simple, but it's not the point. When I tried to submit a bug fix (due to incompatibility with ActiveRecord), they seemingly got pissed off that I found a problem and I was pushed around. While I was testing, I also encountered a major bug with their query implementation, while their testing was tuned in a way that the tests pass. After my previous experience, didn't dare to submit it.


我用MongoMapper已经有一段日子了,不过最近决定要换成MongId。 mongomapper的人太自大,她们有BUG(比如不能跟cucumber兼容)也不愿意改,我提了PATCH他们反而觉得很愤怒,估计他们自我感觉太好,自认为产品美文体。而且mongomapper的查询接口太差劲。我还得做一些修改才能让代码工作。我不介意修改代码,但是由于之前的不好的经验,这次我不敢提PATCH了。。。 而且, mongoid的社区(提交代码的人啊啥的)比mongomapper的强太多了。

5票, mtkd答:
Did some testing with MongoMapper last week, it was stable but I found the query interface a little limited (also some of the AR logic was quirky), switched to Mongoid today and it feels much better to use - and more intuitive if you are used to AR.

上周对MongoMapper做了些测试,它确实稳定,但是查询接口还是不太理想(而且有的active record的逻辑也很奇怪), 今天我换到了mongid上,用起来舒服多了。而且对于熟悉AR的朋友也很直观。  

30票,Nader答:
(2010年一月答案)i've been using both for the past couple weeks. Mongomapper has better support for relational associations (non-embedded) and has greater third-party support. Mongoid has better query support, much better documentation (MM has close to none, though a website is supposedly in the works), Rail 3 support (and thus Devise support) and a slightly more active community on Google Groups.

I ended up going with Mongoid.

这两个我都用了几周。Mongomapper对于关联支持的很好,而且被很多第三方工具支持。 Mongoid的查询接口做的更好,而且文档也强多了(MongoMapper的文档都关掉了(?))。Mongoid还支持RAILS3,它的论坛也更活跃。

(2011年一月追加答案)
Since I originally wrote this answer Mongoid has picked up lots of third-party support and the difference in the communities is even greater. In my opinion Mongoid is more of a clear choice today. Performance should be relatively the same as they both go through the Ruby driver. Though you need to be careful with OM not to construct horrendous documents. – Nader Feb 1 '11 at 0:53

过去一年里,MongoID 被更多的第三方工具支持,所以它们的差距是越来越大了。在我看来,现在Mongid更好了。我们应该毫不犹豫的选择它。 它们在性能上估计差距不大,因为用的都是RUBY的驱动。

其他几个答案也很吸引我,可惜被关掉了:
Which Rails Object Mapper to choose for MongoDB? [closed]

从这个文章(http://praktikanten.brueckenschlaeger.org/2010/11/23/do-i-use-mongoid-mongomapper-or-mongomatic-as-my-ruby-orm-for-mongodb) 中 有 三者的对比(mongoid, mongomapper, mongomatic). 其中对于mongomatic的说法是:简单:

mongoid:

    better support for embedded documents
    better support for very large documents (>500kb)
    closer to activerecord, by making use of active model and an arel like query syntax
    very nice and lean documentation to be found on the project website..
(    对embedded documents支持的更好
    对大数据量的documents支持的更好( 》 500 KB)
    更activerecord非常类似。使用了arel查询。
    简明扼要的教程,非常棒。)

mongomapper:

    better support for reference associations
    supposedly it has a bigger community, or at least still had a bigger community last summer
    better plugin interface
(对关联支持的更好, 社区很大(起码在写文章的时候,2010年夏天), 对PLUGIN支持的更好)

mongomatic

    supposedly it’s faster. there is a benchmark posted on some blog. The benchmark itself can be downloaded on Github
    it says it focusses on simplicity

(据说是最快的,官方文档说,它注重的是使用简单)

更多的文章都是2010年的了。。。呃。。。有点儿老旧,我还是用mongoid的(忙高一的)

Back