Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

CouchFoo: Like ActiveRecord, but for CouchDB

By Peter Cooper / February 11, 2009

couchdb.pngApache CouchDB is a "distributed, fault-tolerant and schema-free document-oriented database accessible via a RESTful HTTP/JSON API" that has received quite a bit of publicity in developer circles in the past year. It's written in Erlang, so has all of the scalability and flexibility the Erlang environment brings to the table, but as a RESTful service, you can use it from pretty much anywhere.

George Palmer, a UK-based Rails developer, wanted to use CouchDB but found the existing libraries (such as RelaxDB, CouchREST, ActiveCouch and CouchPotato) lacking - not that they are, as such, but they didn't fit George's needs. George wanted something that was as ActiveRecord-like as possible, so he developed CouchFoo (a.k.a. couch_foo) - an ActiveRecord-style interface to CouchDB.

Basic operations (creating records, finding, and even dynamic finders) are much the same as with ActiveRecord, but there have been some additions to deal with the differences in CouchDB (such as defining properties to get typing or view definitions). Associations (has_many, etc) also work as expected.

This is a clever bit of work on George's part and I know that based on the strong feedback he's had, he's decided to submit a RailsConf proposal on CouchFoo. After taking a look at it, I can only hope his talk gets accepted as I'd love to hear more from someone in the know.

As an aside, back in September 2008, PeepCode released a CouchDB with Rails screencast.

Comments

  1. Mislav says:

    Worst name ever in the series of foo stuff.

    However I'm pleased so many adapters exist for CouchDB and that there's constant striving for perfection among developers.

  2. tonyc says:

    I'd rather see work go into the DataMapper CouchDB adapter, myself.

    http://github.com/datamapper/dm-more/tree/63327515cc4430a7a59c717afec5c14c9f299d3d/adapters/dm-couchdb-adapter

  3. Basaah says:

    Just tried couchDB out, it is really cool.
    combined with CouchFoo absolutely killing.
    I wonder if it plays along nice with rails.

    Now let's do a few performance test with CouchFoo in rails.

  4. Peter Cooper says:

    I asked George why he wrote this when there are already so many alternatives, and on the Datamapper front he said there were no docs, it was dependency hell, and views had to be defined manually (as a non-user, I can't elaborate on that).

    In any case, I'd much rather someone produce something new than get dissuaded and give up on improving something that already exists.

  5. Sam Figueroa says:

    Railsenvy podcast is gonna love this. Finally a plugin that ends in foo again :P

  6. Peter Cooper says:

    Well get ready, I hear it's going to be on there.

  7. George Palmer says:

    @tonyc I had quite a lot of problems with the DM adapter myself (no associations, incomplete doc) and critically it doesn't manage views automatically (views are a bit like indexes over a subset of the documents in your database).

    @basaah - very interested to hear any results you get there - dm me on twitter @Georgio_1999

    @mislav, @sam - What can I say? I guess naming isn't my strong point!! ;)

  8. Peter Cooper says:

    Thanks for following up, George. :) The name doesn't matter anyway, as long as it's pronounceable and not offensive.

  9. Wesley Beary says:

    @george I'm the current maintainer of the DM adapter, and realize it needs work. Time has been at a premium for me, but I am rewriting it to include better view generation. Updated docs should follow, but were there specific things that were unclear? Could you details your dependency issues so we can track them down? Associations should work the same as they do for other DataMapper models, what issues did you have? I'd love to make the adapter better, so any details you could provide would be greatly appreciated.

  10. ActsAsFlinn says:

    Why are there so many couchdb adapters trying to be activerecord? Seems like ar tries to address relational db suckage while couchdb addresses data in a totally different way.

Other Posts to Enjoy

Twitter Mentions