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

VERSION

Version 0.01

SYNOPSIS

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

    use Net::CouchDb;

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

    my $doc = Net::CouchDb::Document->new;
    $doc->colours = [qw(blue green orange)];

    $test->put($doc);

METHODS

new

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

  • host: Hostname of server

  • port: Port of server

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

  • conn_cache: Optionally provide a LWP::ConnCache object to cache connections to CouchDb.

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.

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.

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.

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.