line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: ArangoDB Database object |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Arango::Tango::Database; |
4
|
|
|
|
|
|
|
$Arango::Tango::Database::VERSION = '0.018'; |
5
|
5
|
|
|
5
|
|
1990
|
use Arango::Tango::Cursor; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
158
|
|
6
|
5
|
|
|
5
|
|
37
|
use Arango::Tango::API; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
100
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
121
|
|
9
|
5
|
|
|
5
|
|
26
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
1384
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
12
|
|
|
|
|
|
|
Arango::Tango::API::_install_methods "Arango::Tango::Database" => { |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
delete_collection => { |
15
|
|
|
|
|
|
|
rest => [ delete => '{{database}}_api/collection/{colname}' ], |
16
|
|
|
|
|
|
|
signature => [ 'colname' ], |
17
|
|
|
|
|
|
|
inject_properties => [ { prop => 'name', as => 'database' } ], |
18
|
|
|
|
|
|
|
}, |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
get_indexes => { |
21
|
|
|
|
|
|
|
rest => [ get => '{{database}}_api/index?collection={colname}' ], |
22
|
|
|
|
|
|
|
signature => [ 'colname' ], |
23
|
|
|
|
|
|
|
inject_properties => [ { prop => 'name', as => 'database' } ] |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
create_ttl_index => { |
27
|
|
|
|
|
|
|
rest => [ post => '{{database}}_api/index?collection={colname}' ], |
28
|
|
|
|
|
|
|
signature => [ 'colname' ], |
29
|
|
|
|
|
|
|
inject_properties => [ { prop => 'name', as => 'database' } ], |
30
|
|
|
|
|
|
|
schema => { |
31
|
|
|
|
|
|
|
name => { type => 'string' }, |
32
|
|
|
|
|
|
|
type => { type => 'string', enum => ['ttl'] }, |
33
|
|
|
|
|
|
|
fields => { type => 'array', items => { type => 'string' } }, |
34
|
|
|
|
|
|
|
expireAfter => { type => 'integer' } |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
create_collection => { |
39
|
|
|
|
|
|
|
rest => [ post => '{{database}}_api/collection' ], |
40
|
|
|
|
|
|
|
schema => { |
41
|
|
|
|
|
|
|
keyOptions => { type => 'object', additionalProperties => 0, params => { |
42
|
|
|
|
|
|
|
allowUserKeys => { type => 'boolean' }, |
43
|
|
|
|
|
|
|
type => { type => 'string', default => 'traditional', enum => [qw'traditional autoincrement uuid padded'] }, |
44
|
|
|
|
|
|
|
increment => { type => 'integer' }, |
45
|
|
|
|
|
|
|
offset => { type => 'integer' }, |
46
|
|
|
|
|
|
|
}}, |
47
|
|
|
|
|
|
|
journalSize => { type => 'integer' }, |
48
|
|
|
|
|
|
|
replicationFactor => { type => 'integer' }, |
49
|
|
|
|
|
|
|
waitForSync => { type => 'boolean' }, |
50
|
|
|
|
|
|
|
doCompact => { type => 'boolean' }, |
51
|
|
|
|
|
|
|
shardingStrategy => { |
52
|
|
|
|
|
|
|
type => 'string', |
53
|
|
|
|
|
|
|
default => 'community-compat', |
54
|
|
|
|
|
|
|
enum => ['community-compat', 'enterprise-compat', 'enterprise-smart-edge-compat', 'hash', 'enterprise-hash-smart-edge']}, |
55
|
|
|
|
|
|
|
isVolatile => { type => 'boolean' }, |
56
|
|
|
|
|
|
|
shardKeys => { type => 'array', items => {type => 'string'} }, |
57
|
|
|
|
|
|
|
numberOfShards => { type => 'integer' }, |
58
|
|
|
|
|
|
|
isSystem => { type => 'booean' }, |
59
|
|
|
|
|
|
|
type => { type => 'string', default => '2', enum => ['2', '3'] }, |
60
|
|
|
|
|
|
|
indexBuckets => { type => 'integer' }, |
61
|
|
|
|
|
|
|
distributeShardsLike => { type => 'string' }, |
62
|
|
|
|
|
|
|
name => { type => 'string' } |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
builder => sub { |
65
|
0
|
|
|
|
|
|
my ($self, %params) = @_; |
66
|
0
|
|
|
|
|
|
return Arango::Tango::Collection->_new(arango => $self, database => $params{database}, 'name' => $params{name}); |
67
|
|
|
|
|
|
|
}, |
68
|
5
|
|
|
5
|
|
378
|
signature => [ 'name' ], |
69
|
|
|
|
|
|
|
inject_properties => [ { prop => 'name', as => 'database' } ] |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _new { |
76
|
0
|
|
|
0
|
|
|
my ($class, %opts) = @_; |
77
|
0
|
|
|
|
|
|
return bless {%opts} => $class; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub delete { |
81
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
82
|
0
|
|
|
|
|
|
return $self->{arango}->delete_database($self->{name}); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub cursor { |
86
|
0
|
|
|
0
|
1
|
|
my ($self, $aql, %opts) = @_; |
87
|
0
|
|
|
|
|
|
return Arango::Tango::Cursor->_new(arango => $self->{arango}, database => $self->{name}, query => $aql, %opts); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub collection { |
95
|
0
|
|
|
0
|
1
|
|
my ($self, $name) = @_; |
96
|
0
|
|
|
|
|
|
my @match = grep { $_->{name} eq $name } @{$self->list_collections}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if (scalar(@match)) { |
98
|
0
|
|
|
|
|
|
return Arango::Tango::Collection->_new(arango => $self->{arango}, database => $self->{name}, 'name' => $name); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
else { |
101
|
0
|
|
|
|
|
|
die "Arango::Tango | Collection not found in database $self->{name}." |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub list_collections { |
106
|
0
|
|
|
0
|
1
|
|
my ($self, %opts) = @_; |
107
|
0
|
|
|
|
|
|
return $self->{arango}->_api( list_collections => { %opts, database => $self->{name} } )->{result}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub get_access_level { |
112
|
0
|
|
|
0
|
1
|
|
my ($self, $username, $collection) = @_; |
113
|
0
|
|
|
|
|
|
return $self->{arango}->get_access_level( $username, $self->{name}, $collection); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub clear_access_level { |
117
|
0
|
|
|
0
|
1
|
|
my ($self, $username, $collection) = @_; |
118
|
0
|
|
|
|
|
|
return $self->{arango}->clear_access_level($username, $self->{name}, $collection); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub set_access_level { |
122
|
0
|
|
|
0
|
1
|
|
my ($self, $username, $grant, $collection) = @_; |
123
|
0
|
|
|
|
|
|
return $self->{arango}->set_access_level($username, $grant, $self->{name}, $collection); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |