Erlang 的 ActiveRecord
我正在继续深入研究 Erlang。我正在考虑使用 Erlang 开始我的下一个 Web 项目,在这个阶段,我真正怀念 Ruby on Rails 的唯一东西就是 ActiveRecord。
Erlang 有没有好的替代技术?
更新: 我最接近的解决方案是 ErlyDB,它是 ErlyWeb 的一个组件。
ErlyDB是一个数据库抽象层 Erlang 的生成器。 ErlyDB 结合 数据库元数据和用户提供的 元数据来生成函数 让您执行常见的数据访问 以直观的方式进行操作。它 还提供了一个单一的 API 来工作 使用不同的数据库引擎 (虽然目前只有MySQL 支持),让您编写便携的 数据访问代码。
I am continuing to delve into Erlang. I am thinking of starting my next web project using Erlang, and at this stage the only thing I will really miss from Ruby on Rails is ActiveRecord.
Is there a good alternative technology for Erlang?
Update:
The closest I have come to a solution is to ErlyDB, a component of ErlyWeb.
ErlyDB is a database abstraction layer
generator for Erlang. ErlyDB combines
database metadata and user-provided
metadata to generate functions that
let you perform common data access
operations in an intuitive manner. It
also provides a single API for working
with different database engines
(although currently, only MySQL is
supported), letting you write portable
data access code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
一些谷歌搜索显示 Couchdb 的 libs/clients/wrappers 描述了“像 CouchFoo 这样的 ActiveRecord 库”,并建议避开:
http://upstream-berlin.com/2009/03/31/the-case-of-activerecord-vs-couchdb/
http://debasishg.blogspot.com/2009 /04/framework-inertia-couchdb-and-case-of.html#
至于你对“尚不适合网络应用程序”的评论,我认为这些部分就在那里:mochiweb、couch、雅司病、氮气、埃利网。当然,有一些强大的工具,非常不同的范例,来自 Rails、django 和 PHP。
Some googling reveals libs / clients / wrappers for Couchdb described "ActiveRecord like libraries like CouchFoo", and advise to steer clear:
http://upstream-berlin.com/2009/03/31/the-case-of-activerecord-vs-couchdb/
http://debasishg.blogspot.com/2009/04/framework-inertia-couchdb-and-case-of.html#
as to your comment on "not suited for web apps yet", I think the pieces are there: mochiweb, couch, yaws, nitrogen, erlyweb. There's some powerful tools, very different paradigm, certainly, from rails, django and PHP.
嗯,ActiveRecord 的主要优点(据我所知)是:
使用 Mnesia:
然而,没有验证和回调的解决方案...
那么,ActiveRecord 中还有什么是 Mnesia 所缺少的呢?
Well, the major advantages of ActiveRecord (as I see it) are:
With Mnesia:
No solutions for validating and callbacks, however...
So, what else do you have in ActiveRecord that is lacking in Mnesia?
我认为在撰写本文时还没有真正存在。这可能是因为用 erlang 编写的系统类型以及编写它们的人员类型并不真正需要关系数据库。我看到更多使用 mnesia、CouchDB、Tokyo Cabinet 和其他此类替代数据库技术的代码。
这并不是说有人可能不想创建活动记录之类的东西。只是还没有真正需要。也许你会是第一个? :-)
I don't think there really is at the time of this writing. That may be because the kinds of systems being written in erlang and the type of people writing them don't really call for Relational Databases. I see much more code using mnesia, CouchDB, Tokyo Cabinet and other such alternative database technologies.
That's not to say someone might not want to create something like active record. It's just hasn't really been a need yet. Maybe you will be the first? :-)
您可能对 Chicago Boss 的“BossRecords”感兴趣:
http://www.chicagoboss.org/api- record.html
它们非常明确地以 Active Record 模式为模型,并使用大量编译器魔法来使语法非常干净。 BossRecords 支持保存/验证以及 has_many/belongs_to 关联。数据模型中的属性可通过生成的函数使用(例如“Employee:first_name()”)。
You might be interested in Chicago Boss's "BossRecords":
http://www.chicagoboss.org/api-record.html
They are quite explicitly modeled on the Active Record pattern, and use a lot of compiler magic to make the syntax squeaky clean. BossRecords support save/validate as well as has_many/belongs_to associations. Attributes in your data model are made available through generated functions (e.g. "Employee:first_name()").