NAME
CouchDB::Client::DB - CouchDB::Client database
SYNOPSIS
use CouchDB::Client;
...
DESCRIPTION
This module represents databases in the CouchDB database.
We don't currently handle the various options available on listing all documents.
METHODS
- new
-
Constructor. Takes a hash or hashref of options, both of which are required:
name
being the name of the DB (do not escape it, that is done internally, however the name isn't validated, you can usevalidName
for that) andclient
being a reference to the parentCouch::Client
. It is not expected that you would use this constructor directly, but rather that would would go throughCouch::Client->newDB
. - validName $NAME
-
Returns true if the name is a valid CouchDB database name, false otherwise.
- dbInfo
-
Returns metadata that CouchDB maintains about its databases as a Perl structure. It will throw a
CouchDB::Client::Ex::ConnectError
if it can't connect. Typically it will look like:{ db_name => "dj", doc_count => 5, doc_del_count => 0, update_seq => 13, compact_running => 0, disk_size => 16845, }
- create
-
Performs the actual creation of a database. Returns the object itself upon success. Throws a
CouchDB::Client::Ex::DBExists
if it already exists, or aCouchDB::Client::Ex::ConnectError
for other problems. - delete
-
Deletes the database. Returns true on success. Throws a
CouchDB::Client::Ex::NotFound
if the DB can't be found, andCouchDB::Client::Ex::ConnectError
for other problems. - newDoc $ID?, $REV?, $DATA?, $ATTACHMENTS?
-
Returns a new
CouchDB::Client::Doc
object, optionally with the given ID, revision, data, and attachments. Note that this does not create the actual document, simply the object. For constraints on these fields please look at<<CouchDB::Client::Doc-
new>>> - listDocIdRevs %ARGS?
-
Returns an arrayref containing the ID and revision of all documents in this DB as hashrefs with
id
andrev
keys. Throws aCouchDB::Client::Ex::ConnectError
if there's a problem. Takes an optional hash of arguments matching those understood by CouchDB queries. - listDocs %ARGS?
-
The same as above, but returns an arrayref of
CouchDB::Client::Doc
objects. Takes an optional hash of arguments matching those understood by CouchDB queries. - docExists $ID, $REV?
-
Takes an ID and an optional revision and returns true if there is a document with that ID in this DB, false otherwise. If the revision is provided, note that this will match only if there is a document with the given ID and its latest revision is the same as the given one.
- newDesignDoc $ID?, $REV?, $DATA?
-
Same as above, but instantiates design documents.
- listDesignDocIdRevs %ARGS?
-
Same as above, but only matches design documents.
- listDesignDocs %ARGS?
-
Same as above, but only matches design documents.
- designDocExists $ID, $REV?
-
Same as above, but only matches design documents.
- uriName
-
Returns the name of the database escaped.
- fixViewArgs %ARGS
-
Takes a hash of view parameters expressed in a Perlish fashion (e.g. 1 for true or an arrayref for multi-valued keys) and returns a hash with the same options turned into what CouchDB understands.
- argsToQuery %ARGS
-
Takes a hash of view parameters, runs them through
fixViewArgs
, and returns a query string (complete with leading '?') to pass on to CouchDB.
AUTHOR
Robin Berjon, <robin @t berjon d.t com>
BUGS
Please report any bugs or feature requests to bug-couchdb-client at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CouchDb-Client.
COPYRIGHT & LICENSE
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.