View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Robin Berjon > CouchDB-Deploy > CouchDB::Deploy



Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  


CouchDB::Deploy - Simple configuration scripting to deploy CouchDB databases


    use CouchDB::Deploy;

    db 'my-test-db/', containing {
        doc {
            _id     => 'foo',
            key     => 'value',
            _attachments => {
                'foo.txt'   => {
                    content_type    => 'text/plain',
                    data            => 'RGFodXRzIEZvciBXb3JsZCBEb21pbmF0aW9uXCE=',
                'bar.svg'   => {
                    content_type    => 'image/svg+xml',
                    data            => file 'dahut.svg',
                'circle.html'   => {
                    content_type    => 'text/html;charset=utf-8',
                    data            => base64 <<EOHTML,
        design {
            _id         => '_design/dahuts',
            language    => 'javascript',
            views   => {
                'all'   => {
                    map     => "function(doc) { if (doc.type == 'dahut')  emit(null, doc) }",
    # then run the above as http://my.server:5984/


This module attempts to help with the common issue of deploying databases and updates to database schemata in distributed development settings (which can simply be when you have your own dev box and a server to deploy to).

CouchDB does not have schemata, but it does have views (in design documents) on which methods in your code are likely to rely. At times, you may also wish to have a given document in a database, say the default configuration.

What this module does is:

Currently this is done in Perl, using simple syntax sugar but it is expected that it will be updated to also support a Config::Any approach.


db $DATABASE, containing { CONTENT }

Creates a database with the given name, and adds the content, unless it exists. Keep in mind that CouchDB databases must have a trailing slash in their names.

doc { CONTENT }

Creates a document with that content, unless it is there and up to date. Note that currently only documents with an _id field are supported (otherwise we couldn't do the create-unless-exists logic). The content is of the exact same structure as the JSON one would post to CouchDB.

file $PATH

Reads the file at $PATH, converts it to base64, and returns that on a single line. This is a helper made to assist in creating CouchDB attachments. Note that in the current state it will read the file into memory.

base64 $CONTENT

Returns the content encoded in single-line Base 64.

design { CONTENT }

Creates a design document with those views and parameters, unless it is there and up to date. The content is of the exact same structure as the JSON one would post to CouchDB, except that if the _id field does not start with _design/ it will be automatically added.


Robin Berjon, <robin @t berjon d.t com>


Please report any bugs or feature requests to bug-couchdb-deploy at, or through the web interface at


Copyright 2008 Robin Berjon, all rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: