ArangoDB2
view release on metacpan or search on metacpan
lib/ArangoDB2/Collection.pm view on Meta::CPAN
package ArangoDB2::Collection;
use strict;
use warnings;
use base qw(
ArangoDB2::Base
);
use Data::Dumper;
use JSON::XS;
use ArangoDB2::Document;
use ArangoDB2::Edge;
use ArangoDB2::Index;
my $JSON = JSON::XS->new->utf8;
# params that can be set when creating collection
my @PARAMS = qw(
doCompact isSystem isVolatile journalSize keyOptions name
numberOfShards shardKeys type waitForSync
);
# checksum
#
# GET /_api/collection/{collection-name}/checksum
sub checksum
{
my($self, $args) = @_;
# process args
$args = $self->_build_args($args, ['withData','withRevisions']);
# make request
return $self->arango->http->get(
$self->api_path('collection', $self->name, 'checksum'),
$args,
);
}
# count
#
# get/set count
sub count { shift->_get_set_bool('count', @_) }
# create
#
# POST /_api/collection
#
# return self on success, undef on failure
sub create
{
my($self, $args) = @_;
# process args
$args = $self->_build_args($args, \@PARAMS);
# make request
my $res = $self->arango->http->post(
$self->api_path('collection'),
undef,
$JSON->encode($args),
) or return;
# copy response data to instance
$self->_build_self($res, [@PARAMS, 'id']);
return $self;
}
# delete
#
# DELETE /_api/collection/{collection-name}
sub delete
{
my($self) = @_;
return $self->arango->http->delete(
$self->api_path('collection', $self->name),
( run in 0.803 second using v1.01-cache-2.11-cpan-39bf76dae61 )