/couchdb_ddoc

Easily push design documents into couchdb

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

DEPRECATED.

couchdb_ddoc

Easily push design documents into CouchDB. Useful for deploying static webapps as CouchApps!

couchdb_ddoc adds the ddoc_load_fixture command, which can load a CouchApp into the DB from a .json manifest file.

ddoc_load_fixture http://mycouch:5984/app couchapp.json

.json manifest format

.json manifest files look just like CouchDB Design Documents, with a small difference:

  • views, shows, lists, and filters can point to .js files. The contents of the files will be loaded and appended as stringified functions.
  • _attachments is an object with a path and optional match and ignore fields. The directory will be recursively searched and all files added as attachments. The optional match and ignore fields are an array of Unix-glob-like patterns that can be used to filter the list of files. The path directory name will be treated as the root path.

For example, to load a project with this directory structure:

views/
  my_view.js
shows/
  my_show.js
lists/
  my_filter.js
filters/
  my_filter.js
attachments/
  ...

You could create the following manifest file:

{
  "_id": "_design/app",
  "rewrites": [
    {"from": "/", "to": "index.html"},
    {"from": "/api", "to": "../../"},
    {"from": "/api/*", "to": "../../*"},
    {"from": "/*", "to": "*"}
  ],
  "views": {
    "my_view": "views/my_view.js"
  },
  "shows": {
    "my_show": "shows/my_show.js"
  },
  "lists": {
    "my_list": "lists/my_list.js"
  },
  "filters": {
    "my_filter": "filters/my_filter.js"
  },
  "_attachments": {
    "path": "_attachments/",
    "ignore": [".DS_Store", "*.psd"]
  }
}

Other Tools

There are some other tools that might also suite your needs:

  • couchapp on NPM - a Node.js module
  • couchapp - Python utility that will deploy your CouchApp using an opinionated directory structure.
  • erica an Erlang tool for pushing CouchApps.

The couchapp wiki is also useful.