Skip to content

Commit

Permalink
support _bulk_docs properties
Browse files Browse the repository at this point in the history
the couchdb wiki defines the 2 types below:

all_or_nothing (boolean)
new_edits (boolean)

http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API#Transactional_Semantics_with_Bulk_Updates
  • Loading branch information
c0decafe committed Jan 16, 2013
1 parent 2c8b767 commit 9529b22
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/AnyEvent/CouchDB/Database.pm
Expand Up @@ -378,10 +378,19 @@ sub detach {
sub bulk_docs {
my ( $self, $docs, $options ) = @_;
my ( $cv, $cb ) = cvcb( $options, undef, $self->json_encoder );

my %props = (); ## _bulk_docs properties go to the request body
foreach my $property (qw(all_or_nothing new_edits)) {
if (my $value = delete $options->{$property}) {
## convert the respective value to the JSON boolean type
$props{$property} = $value eq 'false' ? JSON::false() : JSON::true();
}
}

http_request(
POST => $self->uri . '_bulk_docs',
headers => $self->_build_headers($options),
body => $self->json( { docs => $docs } ),
body => $self->json( { %props, docs => $docs } ),
$cb
);
$cv;
Expand Down

0 comments on commit 9529b22

Please sign in to comment.