Arango-Tango
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Arango/Tango/Database.pm view on Meta::CPAN
inject_properties => [ { prop => 'name', as => 'database' } ],
},
get_indexes => {
rest => [ get => '{{database}}_api/index?collection={colname}' ],
signature => [ 'colname' ],
inject_properties => [ { prop => 'name', as => 'database' } ]
},
create_ttl_index => {
rest => [ post => '{{database}}_api/index?collection={colname}' ],
signature => [ 'colname' ],
inject_properties => [ { prop => 'name', as => 'database' } ],
schema => {
name => { type => 'string' },
type => { type => 'string', enum => ['ttl'] },
fields => { type => 'array', items => { type => 'string' } },
expireAfter => { type => 'integer' }
}
},
create_collection => {
rest => [ post => '{{database}}_api/collection' ],
schema => {
keyOptions => { type => 'object', additionalProperties => 0, params => {
allowUserKeys => { type => 'boolean' },
type => { type => 'string', default => 'traditional', enum => [qw'traditional autoincrement uuid padded'] },
increment => { type => 'integer' },
offset => { type => 'integer' },
}},
journalSize => { type => 'integer' },
replicationFactor => { type => 'integer' },
waitForSync => { type => 'boolean' },
doCompact => { type => 'boolean' },
shardingStrategy => {
type => 'string',
default => 'community-compat',
enum => ['community-compat', 'enterprise-compat', 'enterprise-smart-edge-compat', 'hash', 'enterprise-hash-smart-edge']},
isVolatile => { type => 'boolean' },
shardKeys => { type => 'array', items => {type => 'string'} },
numberOfShards => { type => 'integer' },
isSystem => { type => 'boolean' },
type => { type => 'string', default => '2', enum => ['2', '3'] },
indexBuckets => { type => 'integer' },
distributeShardsLike => { type => 'string' },
name => { type => 'string' }
},
builder => sub {
my ($self, %params) = @_;
return Arango::Tango::Collection->_new(arango => $self, database => $params{database}, 'name' => $params{name});
},
signature => [ 'name' ],
inject_properties => [ { prop => 'name', as => 'database' } ]
}
};
}
sub _new {
my ($class, %opts) = @_;
return bless {%opts} => $class;
}
sub delete {
my $self = shift;
return $self->{arango}->delete_database($self->{name});
}
sub cursor {
my ($self, $aql, %opts) = @_;
return Arango::Tango::Cursor->_new(arango => $self->{arango}, database => $self->{name}, query => $aql, %opts);
}
sub collection {
my ($self, $name) = @_;
my @match = grep { $_->{name} eq $name } @{$self->list_collections};
if (scalar(@match)) {
return Arango::Tango::Collection->_new(arango => $self->{arango}, database => $self->{name}, 'name' => $name,);
}
else {
die "Arango::Tango | Collection not found in database $self->{name}."
}
}
sub list_collections {
my ($self, %opts) = @_;
return $self->{arango}->_api( list_collections => { %opts, database => $self->{name} } )->{result};
}
sub get_access_level {
my ($self, $username, $collection) = @_;
return $self->{arango}->get_access_level( $username, $self->{name}, $collection);
}
sub clear_access_level {
my ($self, $username, $collection) = @_;
return $self->{arango}->clear_access_level($username, $self->{name}, $collection);
}
sub set_access_level {
my ($self, $username, $grant, $collection) = @_;
return $self->{arango}->set_access_level($username, $grant, $self->{name}, $collection);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Arango::Tango::Database - ArangoDB Database object
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.639 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )