Storing design documents and views on the filesystem

Creating databases, design documents, and views

Desktop Couch will automatically create databases and design documents for you on startup by inspecting the filesystem, meaning that you do not need to check in your application whether your views exist. It is of course possible to create views directly through the Records API, but having them created via the filesystem allows managing of the view definitions more easily (they are in separately editable files, which helps with version control) and packaging (the files can be separately stored in a distribution package and installed into the system-level XDG_DATA_DIR rather than the user-level folder).

You will need to restart desktopcouch for changes to take effect.

To create a database

Create a file $XDG_DATA_DIR/desktop-couch/databases/YOUR_DB_NAME/database.cfg

This file can currently be empty (in future it may contain database setup and configuration information).

To create a design document

Create a file $XDG_DATA_DIR/desktop-couch/databases/YOUR_DB_NAME/_design/DESIGN_DOC_NAME/views/VIEW_NAME/map.js containing the map function from your view.

If you also require a reduce function for your view, create a file $XDG_DATA_DIR/desktop-couch/databases/YOUR_DB_NAME/_design/DESIGN_DOC_NAME/views/VIEW_NAME/reduce.js.

This is compatible with the filesystem view structure from ?CouchApp and CouchDBKit.