Skip to content
pull/push CouchDB documents as Javascript files. Handles attachments, too.
CoffeeScript JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Already needs to be renamed... it now fetches documents from a CouchDB as well as puts them back.

The fetch-couch.js app will pull documents from a CouchDB and serialize them into Javascript files as well as store their attachments locally. This makes it easy to edit CouchDB documents in your favorite text editor.

A Grunt watch task will monitor these Javascript files for changes, and upload them and their respective attachments back to your CouchDB.




  cd fetch-couch
  npm install
  echo '{"env":"development"}' > .grunt/environment.json
  grunt coffee:app


Copy settings.example.json to settings.json and set the values to your database and optionally startkey and endkey.


description of settings.json

  "object_dirs": ["filters"],                # list of top-level objects you'd like
                                             # serialized into subdirectories instead
                                             # of the parent javascript document
  "development": {
    "db": "http://localhost:5984/dbname",
    "startkey": "_design/",                  # if specified, will only pull documents
    "endkey":   "_design/z"                  # within the startkey/endkey range
  },                                         # from /dbname/_all_docs
  "production": {
    "db": ""


To switch grunt tasks between your development and production environments:

grunt environment:production
grunt environment:development


To pull documents from CouchDB, just run ./fetch-couch.js.

To pull from your production database:

env=production ./fetch-couch.js


To put them back, or to create new ones, run grunt watch:docs, then edit/save any of the Javascript files in documents/**/filename.js, where filename is the sanitized document _id.

Alternatively, you can use the node couchapp utility to upload the generated documents.


  • Capability to manage apps written in Coffeescript
  • Listen for changes in documents//attachments//* so we can automatically upload whenever an attachment changes locally.
  • Listen to CouchDB _changes feed to trigger automatic update our local files whenever a document in CouchDB changes.
  • Realize other things that need to be done and add them to this list.


This is my first significant stab at writing nodejs or grunt stuff... It may be ugly. Feel free to pitch in and clean it up or contribute. :)

Something went wrong with that request. Please try again.