Skip to content

Instantly share code, notes, and snippets.

@emig
Last active August 29, 2015 14:10
Show Gist options
  • Save emig/5659c5725d6f2d2106d2 to your computer and use it in GitHub Desktop.
Save emig/5659c5725d6f2d2106d2 to your computer and use it in GitHub Desktop.
cli workflow to manage couchDB views using couchapp

So far the easiest way I've found to manage views from the CLI is using couchapp

Please follow the installation instructions on that project. Having a db named db_name we can get any view present in the db using

couchapp clone  "http://127.0.0.1:5984/db_name/_design/document_name" destination_folder

this will create the following structure:

destination_folder
├── _id
├── language
└── views
    ├── view1
    │   └── map.js
    ├── viewn
        └── map.js

It is general better to name destination_folder as the document_name.

You can now make changes locally and push them as:

cd destination_folder && couchapp push "http://127.0.0.1:5984/db_name" && cd ..

Be aware that any change is all-of-nothing, and that any change on the local replica will propagate to the couchdb you are pushing to.

Suport for sharing modules

It seems when using couchapp we can share modules easily. CouchDB implements support for this but it doesn't work in certain cases. For example with CouchDB plugin for Lucene, see issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment