chDB interface on CPAN.
Some are really old (may still work), and all are very thin: CouchDB uses
JSON over HTTP, which can be made to work with two lines of Perl. However,
this leaves a lot of work
undef
result <required>
rownr <required>
values undef
=over 2
=item answer => JSON
The JSON structure from the result which represents this row.
=item doc => L<Couch::DB::Document|Cou
ault to
the C<answer>.
=back
=back
=head2 Accessors
=over 4
=item $obj-E<gt>B<answer>()
The JSON fragment from the result answer which contains the information
about this row.
=item $obj-E<gt>B
RAY
=item members => ARRAY
=back
=back
=head2 Indexes
Three indexes exist:
=over 4
=item * json (Mango)
=item * text (Lucene via Cousteau, phased out)
=item * nouveau (Lucene via Nouveau, sin
SIC'
password Couch::DB undef
server Couch::DB "http://127.0.0.1:5984"
to_json Couch::DB +{ }
to_perl Couch::DB +{ }
to_query Couch::DB +{ }
use
$version
=item auth => 'BASIC'|'COOKIE'
=item password => STRING
=item server => URL
=item to_json => HASH
=item to_perl => HASH
=item to_query => HASH
=item username => STRING
=back
=back
=
>B<jsonText>($json, %options)
Inherited, see L<Couch::DB/"Processing">
=item $obj-E<gt>B<listToPerl>($set, $type, @data|\@data)
Inherited, see L<Couch::DB/"Processing">
=item $obj-E<gt>B<toJSON>(\
use Scalar::Util qw(weaken blessed);
use HTTP::Status qw(HTTP_OK HTTP_NOT_FOUND);
use JSON::PP ();
sub new(@) { my ($class, %args) = @_; (bless {}, $class)->init(\%args) }
sub init($)
{
ng to the
# API documentation :-(
$self->couch
->toJSON($s, bool => qw/conflicts descending include_docs inclusive_end update_seq/)
->toJSON($s, int => qw/limit skip/);
$s;
}
sub __designsRow
$del (@deletes)
{ push @plan, +{ _id => $del->id, _rev => $del->rev, _deleted => JSON::PP::true };
$couch->toJSON($plan[-1], bool => qw/_delete/);
}
@plan or error __x"need at least on document
d, if any.
=back
=head2 Content
B<Warning:> Where Perl does not support the same data-types as JSON, you need to
be very careful when addressing fields from this structure. B<Much better> is
it to
();
use DateTime::Format::ISO8601 ();
use DateTime::Format::Mail ();
use JSON qw/encode_json/;
use List::Util qw(first min);
use Scalar::Util qw(blessed);
use Stora
create_client;
$self->{CD_toperl} = delete $args->{to_perl} || {};
$self->{CD_tojson} = delete $args->{to_json} || {};
$self->{CD_toquery} = delete $args->{to_query} || {};
$self;
}
#-------
aders = $args{headers} ||= {};
$headers->{Accept} ||= 'application/json';
$headers->{'Content-Type'} ||= 'application/json';
#use Data::Dumper;
#warn "CALL ", Dumper \%args;
my $send = $ar
arch } : return {};
$self->couch
->toQuery($query, bool => qw/descending/)
->toQuery($query, json => qw/endkey end_key startkey start_key/);
$query;
}
sub databaseNames(;$%)
{ my ($self, $searc
($self, $rules, %args) = @_;
$self->_clientIsMe(\%args);
my $couch = $self->couch;
$couch->toJSON($rules, bool => qw/cancel continuous create_target winning_revs_only/);
#TODO: warn for upco
if($result) { ... } # same
$result or die;
my $data = $result->answer; # raw JSON response
my $val = $result->values; # interpreted response
# It's not always needed to i
hrough results"> is used.
=item on_values => CODE|ARRAY
Provide a sub which translates incoming JSON data from the server, into
pure perl.
=item paging => HASH
When a call support paging, internal
4
=item $obj-E<gt>B<answer>(%options)
When the response was received, this returns the received json answer
as HASH of raw data: the bare result of the request.
You can better use the L<values()|Co
=item $obj-E<gt>B<deleteIndex>($index, %options)
[CouchDB API "DELETE /{db}/_index/{designdoc}/json/{name}", UNTESTED]
Remove an index from this design document.
=item $obj-E<gt>B<indexDetails>($
') ? "DATETIME($e)"
: $e->isa('Couch::DB::Document') ? 'DOCUMENT('.$e->id.')'
: $e->isa('JSON::PP::Boolean') ? ($e ? 'BOOL(true)' : 'BOOL(false)')
: $e->isa('version') ? "VERSION($e)"
sub update($%)
{ my ($self, $data, %args) = @_;
$data->{_id} = $self->id;
$self->couch
->toJSON($data, bool => qw/autoupdate/)
->check($data->{lists}, deprecated => '3.0.0', 'DesignDoc create
args) = @_;
my $send = +{ %$config, ddoc => $self->id };
my $couch = $self->couch;
$couch->toJSON($send, bool => qw/partitioned/);
$couch->call(POST => $self->db->_pathToDB('_index'),
send =>
f->idBase; # id() would also work
$self->couch->call(DELETE => $self->db->_pathToDB("_index/$id/json/" . uri_escape($index)),
$self->couch->_resultsConfig(\%args),
);
}
sub __searchRow($$$%)
{
alar::Util qw(blessed);
use Mojo::URL ();
use Mojo::UserAgent ();
use Mojo::JSON qw(decode_json);
use HTTP::Status qw(HTTP_OK);
sub init($)
{ my ($self, $args) = @_;
$args->{
if $query;
my @body
= ! defined $send ? ()
: $headers{'Content-Type'} eq 'application/json' ? (json => $send)
: $send;
# $tx is a Mojo::Transaction::HTTP
my $tx = $ua
ontent = $response->content;
return $response->json
unless $response->content->is_multipart;
my $part = $response->content->parts->[0];
decode_json $part->asset->slurp;
}
sub _attachment($$)
{
0], $flags) },
_headers => { Accept => $args{attachments} ? 'multipart/related' : 'application/json' },
),
);
}
sub __delete($)
{ my ($self, $result) = @_;
$result or return;
my $v = $resul
i <required>
auth 'BASIC'
password undef
server "http://127.0.0.1:5984"
to_json +{ }
to_perl +{ }
to_query +{ }
username undef
=over 2
=item api => $version
You M
=E<gt> undef>.
=item to_json => HASH
A table mapping converter name to CODE, to override/add the default PERL to JSON
object conversions for sending structures. See L<toJSON()|Couch::DB/"Processing
">.
=item to_perl => HASH
A table mapping converter name to CODE, to override/add the default JSON to PERL
object conversions for L<Couch::DB::Result::values()|Couch::DB::Result/"When the document i