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


CouchDB-Deploy documentation  | view source Contained in the CouchDB-Deploy distribution.

Index


NAME

Top

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

SYNOPSIS

Top

    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,
                                            <p>Hello!</p>
    EOHTML
                },
            },
        };
        design {
            _id         => '_design/dahuts',
            language    => 'javascript',
            views   => {
                'all'   => {
                    map     => "function(doc) { if (doc.type == 'dahut')  emit(null, doc) }",
                },
            },
        };
    };

    # then run the above as

    my-db-config.pl http://my.server:5984/

DESCRIPTION

Top

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.

SYNTAX SUGAR

Top

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.

AUTHOR

Top

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

BUGS

Top

Please report any bugs or feature requests to bug-couchdb-deploy at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CouchDb-Deploy.

COPYRIGHT & LICENSE

Top


CouchDB-Deploy documentation  | view source Contained in the CouchDB-Deploy distribution.