NAME

CouchDB::Client - Simple, correct client for CouchDB

SYNOPSIS

use CouchDB::Client;
my $c = CouchDB::Client->new(uri => 'https://dbserver:5984/');
$c->testConnection or die "The server cannot be reached";
print "Running version " . $c->serverInfo->{version} . "\n";
my $db = $c->newDB('my-stuff')->create;

# listing databases
$c->listDBs;
$c->listDBNames;

DESCRIPTION

This module is a client for the CouchDB database.

METHODS

new

Constructor. Takes a hash or hashref of options: uri which specifies the server's URI; scheme, host, port which are used if uri isn't provided and default to 'http', 'localhost', and '5984' respectively; json which defaults to a JSON::Any object with utf8 and allow_blessed turned on but can be replaced with anything with the same interface; and ua which is a LWP::UserAgent object and can also be replaced.

testConnection

Returns true if a connection can be made to the server, false otherwise.

serverInfo

Returns a hashref of the server metadata, typically something that looks like { couchdb => "Welcome", version => "0.8.0-incubating"}. It throws an exception if it can't connect.

newDB $NAME

Returns a new CouchDB::Client::DB object for a database of that name. Note that the DB does not need to exist yet, and will not be created if it doesn't.

listDBNames

Returns an arrayref of all the database names that the server knows of. Throws an exception if it cannot connect.

listDBs

Same as above but returns an arrayref of CouchDB::Client::DB objects instead.

dbExists $NAME

Returns true if a database of that name exists, false otherwise.

INTERNAL METHODS

You will use these at your own risk

req $METHOD, $PATH, $CONTENT

$METHOD is the HTTP method to use; $PATH the part of the path that follows scheme://host:port/; and $CONTENT a Perl data structure. The latter, if present, is encoded to JSON and the request is made using the given method and path. The return value is a hash containing a boolean indicating success, a status being the HTTP response code, a descriptive msg, and a json field containing the response JSON.

uriForPath $PATH

Gets a path and returns the complete URI.

AUTHOR

Robin Berjon, <robin @t berjon d.t com> Maverick Edwards, <maverick @t smurfbane d.t org> (current maintainer)

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.