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.
They have a significantly lower number of pull requests and bug/feature submissions than MongoId, i.e. community participation is much lower. Same experience as mine?
I don't know which one has more features right now, but I don't see much future in MongoMapper. I don't mind fixing issues and adding functionality myself, but I do mind situations when they wouldn't fix bugs.
过去几周我一直在使用两者。 Mongomapper 对关系关联(非嵌入式)有更好的支持,并且有更多的第三方支持。 Mongoid 拥有更好的查询支持、更好的文档(MM 几乎没有,尽管据说正在开发一个网站)、Rail 3 支持(以及 Devise 支持)以及 Google Groups 上稍微活跃的社区。
我最终选择了 Mongoid。
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.
Claimed to have better support for relational associations.
Claimed to be more extensible because of it's plugin architecture.
Uses a DSL for querying.
Many-to-many associations are updated only one-sided in MongoMapper.
Less robust support for embedded documents. Updates the entire model even if only a few attributes are modified.
Mongoid
Suggested to be faster than MongoMapper by anecdotal evidence.
More robust support for embedded documents, using MongoDB atomic operations ($set, $push, $pull, etc.) to update nested documents in-place.
Supports bidirectional many-to-many associations.
Uses a chainable ARel-like syntax for querying.
Similarities
Both MongoMapper and Mongoid have websites with good documentation. MongoMapper was long claimed to have bad documentation, but their new website seems to close the gap.
Both can be configured through a YAML file, and both have a rails generator for that file.
另一个问题是选择要返回的字段。两者都支持 only 标准,但 Mongoid 还支持 without 标准,这是 Mongo 原生支持的。
在我看来,Mongoid 只是其 API 更加“全面”和完整,这可能解释了它是一个更大的代码库。它似乎也有更好的记录。
A difference I found is that update_attribute in MongoMapper appears to write the whole document, regardless of what attributes actually changed. In Mongoid it only writes the changed attributes. This can be a significant performance issue for large records. This is particularly true for embedded documents (here labels), e.g.
profile = Profile.find(params[:id])
label = profile.labels.find_or_create_by(idx: params[:idx])
# MongoMapper doesn't have find_or_create_by for embedded docs
# -- you'll have to write custom code
profile.save
On save, MongoMapper will save the whole profile record, but MongoId will use the $set operator with positional logic to only update the label that changed.
Another issue is selecting which fields to return. Both support an only criterion, but Mongoid also supports a without criterion, which is natively supported by Mongo.
It appears to me that Mongoid just is more "rounded" and complete in its API, which probably explains that it's a larger code base. It also appears documented better.
Did you install mongo_ext? I think the performance is more related to the driver than the mapper itself. When looking at the mongo log, I can see without the extension, that the transer seems to have some lags.
Also do as they recommend on the monogdb site, select only the fields you need.
上周用 MongoMapper 做了一些测试,它很稳定,但我发现查询界面有点有限(而且一些 AR 逻辑很奇怪),今天切换到 Mongoid,感觉更好用 - 如果你用过的话会更直观到 AR。
还没有速度结论 - 但切换很轻松 - 它也适用于 Rails 3。
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.
No speed conclusions yet - but the switch over was painless - it works with Rails 3 too.
If you're using Rails3 I'd recommend Mongoid -- it also uses "include" instead of inheritance "<" to persist classes -- using "include" is the better paradigm in Ruby for adding persistence. Mongoid works fine for me with Devise.
To improve performance, try to selectively use the lower-level access, e.g. Moped - I've seen this to be up to 10x faster
1.Mongoid is completely Rails 3 compatible, and uses ActiveModel all over the place (validations, serialization, etc), where MongoMapper is still focused on Rails 2 and uses the validatable gem for its validations.
2.Mongoid officially supports and works on Ruby 1.8.7, 1.9.1, and 1.9.2 head.
3.Mongoid supports embedded documents more robustly, performing the MongoDB atomic operations on any area of the hierarchy internally. ($set, $push, $pull, etc). With MM you need to explicitly tell it to do these operations.
4.MongoMapper has better relational association support and works like this as default.
5.MongoMapper is more extensible, with a plugin architecture that makes it pretty easy for people to extend it with their own libraries. Mongoid does not have this.
6.MM supports identity maps, Mongoid does not.
7.MM has a larger community, and probably more 3rd party library support. I went crazy on documentation and rdoc.
8.Mongoid supports Master/Slave replication clusters. (Writes to master, round robin reads to slaves) MM does not.
9.Mongoid has an extremely rich ARel style criteria API, MM use AR2 style finders.
发布评论
评论(14)
我已经使用 MongoMapper 一段时间了,但决定迁移到 MongoId。原因是隐藏的问题加上对用户的傲慢。我必须克服重重困难才能让 MongoMapper 与 Cucumber 一起工作(最终成功了),并打了几个补丁,即使项目很简单,但这不是重点。当我尝试提交错误修复(由于与 ActiveRecord 不兼容)时,他们似乎很生气,因为我发现了问题并且我被摆布。当我进行测试时,我还遇到了他们的查询实现的一个主要错误,而他们的测试是以测试通过的方式进行调整的。根据我之前的经验,不敢提交。
与 MongoId 相比,它们的拉取请求和错误/功能提交数量明显较少,即社区参与度要低得多。和我的经历一样吗?
我现在不知道哪一个有更多的功能,但我看不到 MongoMapper 有多大的未来。我不介意自己修复问题和添加功能,但我确实介意他们不修复错误的情况。
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.
They have a significantly lower number of pull requests and bug/feature submissions than MongoId, i.e. community participation is much lower. Same experience as mine?
I don't know which one has more features right now, but I don't see much future in MongoMapper. I don't mind fixing issues and adding functionality myself, but I do mind situations when they wouldn't fix bugs.
过去几周我一直在使用两者。 Mongomapper 对关系关联(非嵌入式)有更好的支持,并且有更多的第三方支持。 Mongoid 拥有更好的查询支持、更好的文档(MM 几乎没有,尽管据说正在开发一个网站)、Rail 3 支持(以及 Devise 支持)以及 Google Groups 上稍微活跃的社区。
我最终选择了 Mongoid。
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
第3方库
双方都声称拥有更好的第3方支持。 Github 揭示了以下内容:
值得注意的是,Devise 不支持 MongoMapper。
提交活动
在过去的一年里,看起来 Mongoid 比 MongoMapper 得到了更定期的维护和更新。
MongoMapper
Mongoid
Differences
MongoMapper
Mongoid
Similarities
Configuration
MongoMapper
Mongoid
3rd Party Libraries
Both sides have claimed to have better 3rd party support. Github reveals the following:
Notably, Devise does not support MongoMapper.
Commit Activity
Over the last year, it looks like Mongoid has been more regularly maintained and updated than MongoMapper.
MongoMapper
Mongoid
我发现的一个区别是,MongoMapper 中的
update_attribute
似乎会写入整个文档,而不管实际更改了哪些属性。在 Mongoid 中,它只写入更改的属性。对于大型记录来说,这可能是一个重大的性能问题。对于嵌入文档(这里是标签)尤其如此,例如在保存时,MongoMapper 将保存整个配置文件记录,但 MongoId 将使用具有位置逻辑的
$set
运算符仅更新已更改的标签。另一个问题是选择要返回的字段。两者都支持
only
标准,但 Mongoid 还支持without
标准,这是 Mongo 原生支持的。在我看来,Mongoid 只是其 API 更加“全面”和完整,这可能解释了它是一个更大的代码库。它似乎也有更好的记录。
A difference I found is that
update_attribute
in MongoMapper appears to write the whole document, regardless of what attributes actually changed. In Mongoid it only writes the changed attributes. This can be a significant performance issue for large records. This is particularly true for embedded documents (herelabels
), e.g.On
save
, MongoMapper will save the wholeprofile
record, but MongoId will use the$set
operator with positional logic to only update the label that changed.Another issue is selecting which fields to return. Both support an
only
criterion, but Mongoid also supports awithout
criterion, which is natively supported by Mongo.It appears to me that Mongoid just is more "rounded" and complete in its API, which probably explains that it's a larger code base. It also appears documented better.
你安装了 mongo_ext 吗?
我认为性能与驱动程序比映射器本身更相关。当查看 mongo 日志时,我可以看到没有扩展名,传输器似乎有一些滞后。
还按照他们在 monogdb 网站上的建议进行操作,仅选择您需要的字段。
Did you install mongo_ext?
I think the performance is more related to the driver than the mapper itself. When looking at the mongo log, I can see without the extension, that the transer seems to have some lags.
Also do as they recommend on the monogdb site, select only the fields you need.
上周用 MongoMapper 做了一些测试,它很稳定,但我发现查询界面有点有限(而且一些 AR 逻辑很奇怪),今天切换到 Mongoid,感觉更好用 - 如果你用过的话会更直观到 AR。
还没有速度结论 - 但切换很轻松 - 它也适用于 Rails 3。
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.
No speed conclusions yet - but the switch over was painless - it works with Rails 3 too.
如果您使用 Rails3,我推荐 Mongoid ——它也使用“include”而不是继承“<”持久化类——在 Ruby 中使用“include”是添加持久化的更好范例。
Mongoid 与 Devise 配合使用效果很好。
为了提高性能,请尝试有选择地使用较低级别的访问权限,例如轻便摩托车 - 我发现它的速度提高了 10 倍
If you're using Rails3 I'd recommend Mongoid -- it also uses "include" instead of inheritance "<" to persist classes -- using "include" is the better paradigm in Ruby for adding persistence.
Mongoid works fine for me with Devise.
To improve performance, try to selectively use the lower-level access, e.g. Moped - I've seen this to be up to 10x faster
我认为 Mongoid 在配置和映射方面要好得多。
I think Mongoid is much better at configuration and mapping.
我使用了它们,它们在功能上几乎相同,但看看它的代码统计数据
看起来 MongoMapper 的代码质量要好得多(如果它用更少的资源就能实现同样的效果)。
您可以自己计算此统计数据,这里是分析器 https://github.com/alexeypetrushin/code_stats
I used both of them and they are about to equals in functionality, but look at it's code stats
It looks like MongoMapper has much better code quality (if it does the same with less).
You can calculate this stats by Yourself, here's the analyzer https://github.com/alexeypetrushin/code_stats
我希望性能是相同的,上次我检查 MongoMapper 缺乏 Rails 3 支持 - 所以我现在正在考虑 Mongoid。
I would expect performance to be the same, last time I checked MongoMapper lacked Rails 3 support - so I am looking at Mongoid for now.
sudo gem install mongo_ext
是获得性能的关键。MongoDB 在原始速度方面击败了 CouchDB——尽管 CDB 确实有自己的一系列优势。
基准:http://www.snailinaturtleneck.com/blog/?p=74
sudo gem install mongo_ext
is key to getting performance.MongoDB blows away CouchDB in terms of raw speed – though CDB does have its own set of advantages.
Benchmark: http://www.snailinaturtleneck.com/blog/?p=74
Devise 不支持 MongoMapper,而且我也更喜欢采用 Rails3 方式。所以我改用了 mongoid。
Devise did not support MongoMapper, and I too prefer moving in the Rails3 way. So I switched to mongoid.
Mongoid 完全支持 Rails3 并具有身份映射功能。
更多文档位于 http://mongoid.org
在此处查看性能 http://mongoid.org/performance.html
Mongoid is having a full support with Rails3 and having identity map feature.
More document is at http://mongoid.org
See the performance here http://mongoid.org/performance.html
我希望以下几点能为上述答案增添价值。
1.Mongoid完全兼容Rails 3,并且全部使用ActiveModel
在这个地方(验证、序列化等),MongoMapper 仍然专注于 Rails 2 并使用可验证的 gem 进行验证。
2.Mongoid正式支持并运行在Ruby 1.8.7、1.9.1和1.9.2 head上。
3.Mongoid更强大地支持嵌入文档,在内部层次结构的任何区域执行MongoDB原子操作。 ($set、$push、$pull 等)。对于 MM,您需要明确地告诉它执行这些操作。
4.MongoMapper有更好的关系关联支持,默认是这样工作的。
5.MongoMapper 更具可扩展性,其插件架构使人们可以轻松地使用自己的库来扩展它。 Mongoid 没有这个。
6.MM支持身份映射,Mongoid不支持。
7.MM拥有更大的社区,并且可能有更多的第3方库支持。我对文档和 rdoc 着迷。
8.Mongoid支持Master/Slave复制集群。 (写入主机,循环读取从机)MM 没有。
9.Mongoid拥有极其丰富的ARel风格标准API,MM使用AR2风格查找器。
I hope Below points add values to above answers.
1.Mongoid is completely Rails 3 compatible, and uses ActiveModel all
over the place (validations, serialization, etc), where MongoMapper is still focused on Rails 2 and uses the validatable gem for its validations.
2.Mongoid officially supports and works on Ruby 1.8.7, 1.9.1, and 1.9.2 head.
3.Mongoid supports embedded documents more robustly, performing the MongoDB atomic operations on any area of the hierarchy internally. ($set, $push, $pull, etc). With MM you need to explicitly tell it to do these operations.
4.MongoMapper has better relational association support and works like this as default.
5.MongoMapper is more extensible, with a plugin architecture that makes it pretty easy for people to extend it with their own libraries. Mongoid does not have this.
6.MM supports identity maps, Mongoid does not.
7.MM has a larger community, and probably more 3rd party library support. I went crazy on documentation and rdoc.
8.Mongoid supports Master/Slave replication clusters. (Writes to master, round robin reads to slaves) MM does not.
9.Mongoid has an extremely rich ARel style criteria API, MM use AR2 style finders.