NAME

CouchDB::Client::DesignDoc - CouchDB::Client design documents (views)

SYNOPSIS

$dd->listViews;
# ...
my $res = $dd->queryView('all');

DESCRIPTION

This module represents design documents (containing views) in the CouchDB database.

Design documents are basically documents that have some fields interpreted specifically in CouchDB. Therefore, this is a subclass of CouchDB::Client::Doc and has all of the same functionality except that it will not save attachments.

METHODS

new

Constructor. Same as its parent class but only accepts IDs that are valid for design documents.

views

Read-write accessor for the views. It needs to be in the format that CouchDB expects. Note that this only changes the views on the client side, you have to create/update the object for it to be stored.

contentForSubmit

Same as its parent class but removes attachments.

listViews

Returns a list of all the views defined in this design document.

queryView $VIEW_NAME, %ARGS?

Takes the name of a view in this design document (an exception will be thrown if it isn't there) and an optional hash of query arguments as supported by CouchDB (e.g. startkey, descending, count, etc.) and returns the data structure that the server returns. It will throw exceptions for connection errors too.

The query parameters are expected to be expressed in a Perlish fashion. For instance if one has a boolean value you should use Perl truth and it will work; likewise if you are using multiply-valued keys then simply pass in an arrayref and it will be converted and quoted properly.

The data structure that is returned is a hashref that will contain total_rows and offset keys, as well as a rows field that contains an array ref being the resultset.

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.