NAME

Couchbase::Couch::Base - API For Couch Operations

SYNOPSIS

NYI

DESCRIPTION

All documentation here pertains to Couchbase::Client which is the client object representing a couchbase connection. This manual page documents the Couch (i.e. CouchDB) interface, with some differences

Whereas the 'normal' interface in Couchbase::Client describes the mainly memcached API, this describes dealing with views and design documents.

NOTE: This is a work in progress and the interface is subject to change! You have been warned

All return values, unless otherwise specified, conform to the Couchbase::Couch::HandleInfo which is itself a subclass of Couchbase::Client::Return.

This means the error codes and metadata are found in the returned object, and the actual data may be accessed by using the data method.

Dealing with design documents

Design documents are returned as Couchbase::Couch::Design objects, a subclass of Couchbase::Couch::HandleInfo

Design documents encapsulate one or more views. They are simple JSON objects which this module converts to perl hashes.

couch_design_get($name)

Get the design document with the name $name. $name is not a path, but a simple name. To get a 'development' mode design, simply use "_dev_$name".

couch_design_put($hash_or_json,$path)

Save the design document under the specified path. The first argument may either be an encoded JSON string, or a hash, which this module shall encode for you.

Views

couch_view_slurp($path,%options)

Get all results from a view. $path may be a string path (i.e. the path component of the URI), or an arrayref of [$design, $view].

%options may be a hash of options. Recognized options are directives to this module for behavior, while unrecognized options are passed as-is as query parameters to the view engine.

There are no recognized options for slurp-mode view execution.

This method returns a Couchbase::Couch::HandleInfo object. The actual rows/results may be accessed by calling the rows method on the returned object.

couch_view_iterator($path,%options)

Initialize an iterator object (specifically, a Couchbase::Couch::Handle) for incremental processing of large result sets.

The iterator works as so:

my $iter = $cbo->couch_view_iterator("_design/blog/_view/recent_post");
while (my $row = $iter->next) {
    # do something with $row
}

Where $row is a Couchbase::Couch::ViewRow object (the resultant hash is blessed as-is into this package).

The $path and %options parameters follow the same semantics as in couch_view_slurp with the following recognized options:

ForUpdate

Execute the view query in 'extended' mode. This means to perform some extra work in order to make in-place updates easier. Specifically, this means allowing the shorthand $row->save idiom, as well as including the entire document within each row.

Documents

These methods really just call their memcached equivalents with some extra behavior specific to ensuring values are converted to and from JSON

couch_doc_get($key, ...)

Follows the same semantics as Couchbase::Client's get

couch_doc_store($key,$value,...)

Follows the same semantics as Couchbase::Client's set

SEE ALSO

Couchbase::Couch::Handle - contains documentation for Couchbase::Couch::ViewIterator

Couchbase::Couch::HandleInfo - Documents the Couchbase::Client::Return-like object for fetching view row metadata

Couchbase::Couch::ViewRow - Documents the row objects returned by the iterator.