From e3ea00c3c26e7b280bea1e6fd3eaf357c3fbd360 Mon Sep 17 00:00:00 2001 From: John Beppu Date: Mon, 5 Jan 2009 13:49:25 -0800 Subject: [PATCH] added support for /db/_all_docs URL via the new open_docs() method (by Jan-Felix Wittmanm) --- lib/AnyEvent/CouchDB/Database.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/AnyEvent/CouchDB/Database.pm b/lib/AnyEvent/CouchDB/Database.pm index 1937450..c8c37fe 100644 --- a/lib/AnyEvent/CouchDB/Database.pm +++ b/lib/AnyEvent/CouchDB/Database.pm @@ -112,6 +112,20 @@ sub open_doc { $cv; } +sub open_docs { + my ($self, $doc_ids, $options) = @_; + my ($cv, $cb) = cvcb($options); + $options ||= {}; + $options->{'include_docs'} = 'true'; + http_request( + POST => $self->uri.'_all_docs'.$query->($options), + headers => { 'Content-Type' => 'application/json' }, + body => $json->({"keys" => $doc_ids}), + $cb + ); + $cv; +} + sub save_doc { my ($self, $doc, $options) = @_; if ($options->{success}) { @@ -342,12 +356,18 @@ be compacted, and it returns a condvar. This method is used to request a hashref that contains an index of all the documents in the database. Note that you B get the actual documents. Instead, you get their Cs, so that you can fetch them later. +To get the documents in the result, set parameter C to 1 in the options =head3 $cv = $db->open_doc($id, [ \%options ]) This method is used to request a single CouchDB document by its C, and it returns a condvar. +=head3 $cv = $db->open_docs($ids, [ \%options ]) + +This method is used to request multiple CouchDB documents by their C, and +it returns a condvar. + =head3 $cv = $db->save_doc($doc, [ \%options ]) This method can be used to either create a new CouchDB document or update an