Skip to content

Commit

Permalink
added support for /db/_all_docs URL via the new open_docs() method (b…
Browse files Browse the repository at this point in the history
…y Jan-Felix Wittmanm)
  • Loading branch information
beppu committed Jan 5, 2009
1 parent 070e560 commit e3ea00c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/AnyEvent/CouchDB/Database.pm
Expand Up @@ -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}) {
Expand Down Expand Up @@ -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<DO NOT> get the actual documents.
Instead, you get their C<id>s, so that you can fetch them later.
To get the documents in the result, set parameter C<include_docs> 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<id>, and
it returns a condvar.
=head3 $cv = $db->open_docs($ids, [ \%options ])
This method is used to request multiple CouchDB documents by their C<ids>, 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
Expand Down

0 comments on commit e3ea00c

Please sign in to comment.