ArangoDB2
view release on metacpan or search on metacpan
lib/ArangoDB2/Collection.pm view on Meta::CPAN
$self->database,
$self,
);
}
}
# indexes
#
# register of ArangoDB2::Index objects by name
sub indexes { $_[0]->{indexes} ||= {} }
# info
#
# GET /_api/collection/{collection-name}
sub info
{
my($self) = @_;
return $self->arango->http->get(
$self->api_path('collection', $self->name),
);
}
# isSystem
#
# get/set isSystem
sub isSystem { shift->_get_set_bool('isSystem', @_) }
# isVolatile
#
# get/set isVolatile
sub isVolatile { shift->_get_set_bool('isVolatile', @_) }
# journalSize
#
# get/set journalSize
sub journalSize { shift->_get_set('journalSize', @_) }
# keyOptions
#
# get/set keyOptions
sub keyOptions { shift->_get_set('keyOptions', @_) }
# list
#
# GET /_api/collection
sub list
{
my($self, $args) = @_;
# process args
$args = $self->_build_args($args, ['excludeSystem']);
# make request
return $self->arango->http->get(
$self->api_path('collection'),
$args,
);
}
# load
#
# PUT /_api/collection/{collection-name}/load
sub load
{
my($self, $args) = @_;
# process args
$args = $self->_build_args($args, ['count']);
# make request
return $self->arango->http->put(
$self->api_path('collection', $self->name, 'load'),
$args,
);
}
# numberOfShards
#
# get/set numberOfShards
sub numberOfShards { shift->_get_set('numberOfShards', @_) }
# properties
#
# GET /_api/collection/{collection-name}/properties
#
# or
#
# PUT /_api/collection/{collection-name}/properties
sub properties
{
my($self, $args) = @_;
# process args
$args = $self->_build_args($args, ['journalSize', 'waitForSync']);
# build path
my $path = $self->api_path('collection', $self->name, 'properties');
# make request
my $res = %$args
# if args are passed then set with PUT
? $self->arango->http->put($path, undef, $JSON->encode($args))
# otherwise get properties
: $self->arango->http->get($path);
# copy response data to instance
$self->_build_self($res, \@PARAMS);
return $self;
}
# rename
#
# PUT /_api/collection/{collection-name}/rename
sub rename
{
my($self, $args) = @_;
# make a copy of current name
my $old_name = $self->name;
# process args
$args = $self->_build_args($args, ['name']);
my $res = $self->arango->http->put(
$self->api_path('collection', $self->name, 'rename'),
undef,
$JSON->encode($args),
);
# if rename successful apply changes locally
if ($res && $res->{name} eq $args->{name}) {
# change internal name
$self->name($res->{name});
# unregister old name
delete $self->database->collections->{$old_name};
# register new name
$self->database->collections->{ $res->{name} } = $self;
}
return $self;
}
# revision
#
# GET /_api/collection/{collection-name}/revision
sub revision
{
my($self) = @_;
return $self->arango->http->get(
$self->api_path('collection', $self->name, 'revision'),
);
}
# rotate
#
# PUT /_api/collection/{collection-name}/rotate
sub rotate
{
my($self) = @_;
return $self->arango->http->put(
$self->api_path('collection', $self->name, 'rotate'),
);
}
# shardKeys
#
# get/set shardKeys
sub shardKeys { shift->_get_set('shardKeys', @_) }
# truncate
#
# PUT /_api/collection/{collection-name}/truncate
sub truncate
{
my($self) = @_;
return $self->arango->http->put(
$self->api_path('collection', $self->name, 'truncate'),
);
}
# type
#
# get/set type
sub type { shift->_get_set('type', @_) }
# unload
#
# PUT /_api/collection/{collection-name}/unload
sub unload
{
my($self) = @_;
return $self->arango->http->put(
$self->api_path('collection', $self->name, 'unload'),
);
}
# waitForSync
#
# get/set waitForSync
sub waitForSync { shift->_get_set_bool('waitForSync', @_) }
# withData
#
# get/set withData
sub withData { shift->_get_set_bool('withData', @_) }
# withRevisions
#
# get/set withRevisions
sub withRevisions { shift->_get_set_bool('withRevisions', @_) }
# _class
#
# internal name for class
sub _class { 'collection' }
1;
__END__
=head1 NAME
ArangoDB2::Collection - ArangoDB collection API methods
=head1 METHODS
=over 4
=item new
=item checksum
=item count
=item create
=item delete
=item document
=item documents
=item documentCount
=item doCompact
( run in 0.637 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )