The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::CouchDb - Interface to CouchDb

NO LONGER MAINTAINED

Please note this module is no longer maintained. I recommend you use CouchDB::Client instead (or AnyEvent::CouchDB if that is closer to your needs).

SYNOPSIS

Provides an object oriented interface to the CouchDb REST/JSON API.

use Net::CouchDb;

my $cdb = Net::CouchDb->new(host => "localhost", port => 5984);
$cdb->debug(1);
$cdb->create_db("test");

my $test = $cdb->db("test");

my $doc = $test->new_doc;
$doc->colours = [qw(blue green orange)];

$doc->create;

METHODS

new

Creates a new Net::CouchDb object. Takes the following parameters:

  • host: Hostname of server (defaults to localhost).

  • port: Port of server (defaults to 5984).

  • uri: Optionally specify a URI instead of host and port. (e.g. http://localhost:5984).

  • conn_cache: Either provide a LWP::ConnCache object to cache connections to CouchDb, or set to 0 to disable connection caching. If not supplied Net::CouchDb will automatically use a per-instance cache.

db

Open/connect to a specific database. Returns a Net::CouchDb::Database object.

database

Alias for db.

create_db($name)

Create a new database.

all_dbs

Return a list of all databases

delete_db

Delete a database.

server_info

Returns a data structure with the information from the couchdb "/" URI (notably the version).

debug

Set or get the debug flag (defaults to 0, higher values gives more debug output). This requires that the Data::Dump module is installed.

This can also be enabled via the COUCH_DEBUG environment variable.

log(debug_level, message, [message, ...])

Log a debug message at debug_level.

call($method, $uri, $data)

Make a REST/JSON call. Normally you should use a more specific method, but this provides low-level access if needed.

  • $method is the HTTP method to use.

  • $uri is the HTTP URI to request.

  • $data is a reference which will be converted to JSON data if the request expects one. For a GET request it is converted into URI parameters.

Returns a reference to the returned JSON data in scalar context, in array context returns the HTTP status and the reference.

uri

Return the URI that this instance is pointing at.

AUTHOR

David Leadbeater, <dgl at dgl dot cx>

BUGS

Please report any bugs or feature requests to bug-net-couchdb at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-CouchDb. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

DEVELOPMENT

There is a git repository available at git://code.d.cx/Net-CouchDb, which can be viewed at http://code.d.cx/?p=Net-CouchDb.git.

COPYRIGHT & LICENSE

Copyright 2007 David Leadbeater, 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.