在 Rails 3.1 中从 ActiveRecord 切换到 DataMapper 有多困难?
我正在开始一个新项目,并且可能定义了三个资源。到目前为止还没有太多代码。 (Rails 3.1
)
但我有兴趣尝试 DataMapper
。我已经习惯了 ActiveRecord(并且实际上很喜欢它),但我总是在寻找新事物。另外,我的应用程序使用 Backbone.js
但我不认为这是相关的。
那么像这样切换 ORM“中间应用程序”有多难,您认为 DM 的学习曲线有那么难吗?
PS,我可能会在我的应用程序旁边使用其他引擎。例如 MongoDB 与 Postgres 一起运行。 DM 在那里有优势吗?
I'm starting a new project and I have maybe three resources defined. Not a lot of code so far. (Rails 3.1
)
But I'm interested in trying out DataMapper
. I'm used to ActiveRecord (and actually enjoy it) but I'm always on the lookout for new things. Plus, my application uses Backbone.js
but I don't believe that's relevant.
So how hard is it to switch out the ORM "mid-app" like this and do you think the learning curve to DM is that hard?
PS, there is a chance that I might be using other engines alongside my application. Such as MongoDB running along with Postgres. Will DM be at an advantage there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使用 Datamapper 本身,没有太多的内容,但有一些 Rails 细节需要额外的工作(例如“rails s”中的 SQL 执行时间),而且还有 rake 任务。
查看 dm-rails - 他们有一个模板,您可以使用该模板来配置初始 Rails 项目,该项目为 Datamapper 设置了所有内容。您还可以查看源代码并了解它如何挂钩所有内容。如果您将数据库支持的会话存储与 Datamapper 一起使用,则会出现一个小问题,这涉及到猴子补丁。
To use Datamapper itself, there isn't much to it but it is some of the Rails niceties that require additional work (like the SQL execution times in "rails s") and there is also the rake tasks.
Check out dm-rails - They have a template that you use to provision the initial Rails project that sets it up with everything for Datamapper. You can also look through the source and see how it hooks everything. There is a small issue if you use database-backed session stores with Datamapper, which involves a monkey patch.