开发者

Is there any Ruby CouchDB wrapper which behaves like ActiveRecord adapter?

开发者 https://www.devze.com 2023-02-10 08:18 出处:网络
There are several good CouchDB wrappers available, like SimplyStored, CouchFoo, CouchRest and others, but none of them seems to mimic ActiveRecord adapter. To be precise, what I need is:

There are several good CouchDB wrappers available, like SimplyStored, CouchFoo, CouchRest and others, but none of them seems to mimic ActiveRecord adapter. To be precise, what I need is:

  1. Setting database access parameters in config/database.yml in a common way instead of adding some magical commands to config/environments.rb.
  2. Support for code-generating commands like rails generate scaffold or rails generate model.
  3. Support for the features that RDBs and DDBs have in common (transactions and so on).

What I do not expect them to do:

  1. Be fully compatible with relational database adapters (in other words, I do not expect everything to work after just changing adapter: couchdb to adapter: sqlite3).
  2. Mimic any particular ORM feature.

So, the question is, does such adapter already exist? And if not, is there some reason people do not implement this? I am 开发者_开发知识库thinking about writing such adapter myself or maybe adding this functionality to some existing wrapper, but I'd like to make sure I don't miss something.


So, the question is, does such adapter already exist?

No, it doesn't.

And if not, is there some reason people do not implement this?

Because CouchDB is not a relational database. If you need a RDB, then you probably want to use ActiveRecord, not forcing a Document Database to behave like a Relational Database.

CouchRest CouchModel is a project which uses an API very similar to ActiveRecord. In facts, it implements ActionModel without loosing the focus that CouchDB is not a Relational Database.


While not exactly what you are looking for, @langalex' CouchPotato, which builds on CouchRest is an approximation: https://github.com/langalex/couch_potato

0

精彩评论

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