Narkisr - blog

Narkisr.com where code writes itself.


10
Apr 10

Update Couchdb via FUSE

FUSE is one of my favorite projects it really makes FS development accessible, it can abstract almost any resource as a file system making it first class citizen in the UNIX realm,
an option that I was thinking about is to represent a Couchdb database as a folder. A possible use case might be a Dropbox/Ubuntu-one like clone (taking an advantage on Couchdb excellent replication) another one might be "greping" documents, the entire UNIX set will be able to process them.

Apparently im not the first to think about this, enter Couchdb FUSE, this project enables the manipulation of document attachments (files), the install process under Ubuntu is a bit undocumented, I had to figure it out myself:

    $ sudo aptitude install libfuse2 fuse-utils# installing fuse
    $ sudo aptitude install python-setuptools # this installs easy_install
    $ sudo aptitude install python-dev libfuse-dev # fuse-python requires it
    $ sudo easy_install couchdb
    $ sudo easy_install couchdb-fuse
    $ sudo easy_install fuse-python

Now we should be able to mount a single document attachments like so:

    $ mkdir couchmount
    $ curl -X PUT http://localhost:5984/fuse
    $ curl -X POST http://localhost:5984/fuse -H 'Content-Type: text/javascript; charset=utf-8' -d '{}' # an empty document, next step will use its id
    $ couchmount http://localhost:5984/fuse/6a53b4e951ea836b7fef55e7afafcd7a  couchmount
    $ touch couchmout/bla
    $ curl -X GET http://localhost:5984/fuse/6a53b4e951ea836b7fef55e7afafcd7a 
    {"_id":"6a53b4e951ea836b7fef55e7afafcd7a","_rev":"2-d9a4307289432688cd5a2f2d5c605f88","_attachments":{"bla":{"stub":true,"content_type":"","length":0,"revpos":2}}}
This is all nice but lacks couple of features that id like to have:
  • Mounting an entire DB & exposing all the documents.
  • Make the entire document editable (not just the attachments).
  • Enable full CRUD access to the DB.
I guess that this calls for another solution, do you have any thing in mind?


This website content by Ronen Narkis is licensed under a Creative Commons Attribution 2.5 Israel License, based on a work at narkisr.com, Permissions beyond the scope of this license may be available at narkisr.com.