NAME

DB::CouchDB::Schema - A Schema driven CouchDB module

VERSION

0.2.1

RATIONALE

After working with several of the CouchDB modules already in CPAN I found myself dissatisfied with them. DB::CouchDB::Schema is intended to approach the CouchDB Workflow from the standpoint of the schema. It provides tools for dumping and restoring the views that define your schema and for querying the views in your schema easily.

METHODS

new(%opts)

my $schema = DB::CouchDB::Schema->new(host => $hostname,
                                      port => $db_port, # optional defaults to 5984
                                      db   => $databse_name);

Constructor for a CouchDB Schema.

load_schema_from_script($script)

loads a CouchDB Schema from a json script file. This is sort of like the DDL in a SQL DB only its essentially just a list of _design/* documents for the CouchDB

load_schema_from_db()

Loads a CouchDB Schema from the Database on the server. this can later be dumped to a file and pushed to a database using load_schema_from_script.

This method gets called for you during object construction so that you will have a current look at the CouchDB Schema stored in your object.

schema

Returns the database schema as an arrayref of _design/ docs serialized to perl objects. You can update you schema by modifying this object if you know what you are doing. Then push the modifications to your database.

dump($pretty)

Returns the database schema as a json string.

dump($pretty)

Pushes the current schema stored in the object to the database. Used in combination with load_schema_from_script you can restore or create databse schemas from a json defintion file.

If $pretty is true then the string will be pretty printed.

get($doc)

wipe

Wipes the schema from the database. Only deletes the views not data and only deletes views it knows about from either of the load_schema_from_* methods.

ACCESSORS

When DB::CouchDB objects are new'ed up they create accessors for the views defined in the Database. Calling $schema-view_name(\%view_args)> will return you the data for the views. See DB::CouchDB view method for more information on the args for a view.