2009/01/30

Rest with Merb: CouchDB resources



I've been studying couchdb. There are several ways to use couchDB with merb. CouchRest, dm-couchdb-adapter, relaxdb. At the beginning, I've focussed on dm-couchdb-adapter. Because there is a good example, the muddle. It works on my local machine too. I looked into the source codes, and it was not easy to understand them. My head was full of relational database concepts, and it prevented me to go further. I decided to spend more time on couchDB. I asked @merbist via twitter that which would be the proper way to use couchDB. And he answered that "Couchrest for sure, the 2 other ones don't use couch properly"

These are the resources to start.

There is a ruby interface written by jchris, Couchrest. He has a plan to launch Couchrest::Model seperately [link].

And Couchview has been replaced by couchapp [link](I've followed Peepcode screencast, and spent some time to figure out why "couchview" command is not working.)

$ couchapp
Usage: /opt/local/bin/couchapp [options] (push|generate)
-q, —quiet Omit extra debug info
-h, —help Display detailed help and exit
-v, —version Display version number

Here is what jchris said about couchapp at couchrest google group[link]
====================
Couchapp is equivalent to couchview, except for a few details about
how it expects to see documents stored on the filesystem.

If I recall correctly, couchview takes something like this

views/test-map.js
views/test-reduce.js

and pushes it to the views member of a design doc, which you'd specify
on the command line, with a default of falling back to a directory name. Couchview does that job just fine, but it is no generalized to handle the other functions that can be stored in a design doc.

the CouchApp script takes a filesystem and pushes it transparently to a design doc, so the on-disk layout it expects is a little different:

views/test/map.js
views/test/reduce.js
validate_doc_update.js
shows/post.js
lists/index.js
_attachments/images/example.png
_attachments/foo/bar.html

you are free to leave any of that out (so if you only care about views then you should be able to use it just fine.)

currently the python version of couchapp also has the ability to "clone" from a url. I'm working on getting the ruby version back up to speed, but for now you might be happiest installing the python version.


Things move so fast around couchDB and couchrest that one article is not proper to summarize them. I will post time to time about it.
blog comments powered by Disqus