DB::CouchDB::Schema - A Schema driven CouchDB module
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.
my $schema = DB::CouchDB::Schema->new(host => $hostname, port => $db_port, # optional defaults to 5984 db => $databse_name);
Constructor for a CouchDB Schema.
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
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.
dumps the entire db to a file for backup
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.
Returns the database schema as a json string. if $pretty is true then the dump will be pretty printed
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.
create a doc on the server. accepts the following arguments
id => 'the name of the document' #optional if you want to let CouchDB name it for you doc => $object #not optional $object is the document to store in CouchDB
create a new database in CouchDB and return a DB::CouchDB::Schema object for it.
It takes the following argument
db => 'database name' # not optional the name of the database to create.
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.
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.