line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: ArangoDB Collection object |
2
|
|
|
|
|
|
|
package Arango::Tango::Collection; |
3
|
|
|
|
|
|
|
$Arango::Tango::Collection::VERSION = '0.017'; |
4
|
5
|
|
|
5
|
|
32
|
use warnings; |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
169
|
|
5
|
5
|
|
|
5
|
|
34
|
use strict; |
|
5
|
|
|
|
|
39
|
|
|
5
|
|
|
|
|
114
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
27
|
use Arango::Tango::API; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
1215
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
5
|
|
|
5
|
|
272
|
Arango::Tango::API::_install_methods "Arango::Tango::Collection" => { |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
## Document Management -- Keeping here for now. |
13
|
|
|
|
|
|
|
document => { |
14
|
|
|
|
|
|
|
rest => [ get => '{{database}}_api/document/{name}/{key}' ], |
15
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ], |
16
|
|
|
|
|
|
|
signature => ['key'], |
17
|
|
|
|
|
|
|
## FIXME - Header parameters still not supported |
18
|
|
|
|
|
|
|
}, |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
## Collection Management |
21
|
|
|
|
|
|
|
load_indexes => { |
22
|
|
|
|
|
|
|
rest => [ put => '{{database}}_api/collection/{name}/loadIndexesIntoMemory' ], |
23
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ], |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
rename => { |
27
|
|
|
|
|
|
|
rest => [ put => '{{database}}_api/collection/{collection}/rename' ], |
28
|
|
|
|
|
|
|
inject_properties => [ 'database', { prop => 'name', as => 'collection' } ], |
29
|
|
|
|
|
|
|
signature => [ 'name' ], |
30
|
|
|
|
|
|
|
schema => { name => { type => 'string' }}, |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
properties => { |
34
|
|
|
|
|
|
|
rest => [ get => '{{database}}_api/collection/{name}/properties' ], |
35
|
|
|
|
|
|
|
inject_properties => ['database', 'name' ], |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
truncate => { |
39
|
|
|
|
|
|
|
rest => [ put => '{{database}}_api/collection/{name}/truncate' ], |
40
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ] |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
revision => { |
44
|
|
|
|
|
|
|
rest => [ get => '{{database}}_api/collection/{name}/revision' ], |
45
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ], |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
info => { |
49
|
|
|
|
|
|
|
rest => [ get => '{{database}}_api/collection/{name}' ], |
50
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ], |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
recalculate_count => { |
54
|
|
|
|
|
|
|
rest => [ put => '{{database}}_api/collection/{name}/recalculateCount' ], |
55
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ], |
56
|
|
|
|
|
|
|
}, |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
rotate => { |
59
|
|
|
|
|
|
|
rest => [ put => '{{database}}_api/collection/{name}/rotate' ], |
60
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ], |
61
|
|
|
|
|
|
|
}, |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
figures => { |
64
|
|
|
|
|
|
|
rest => [ get => '{{database}}_api/collection/{name}/figures' ], |
65
|
|
|
|
|
|
|
schema => { withRevisions => { type => 'boolean' }, withData => {type=>'boolean' }}, |
66
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ], |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
count => { |
70
|
|
|
|
|
|
|
rest => [ get => '{{database}}_api/collection/{name}/count' ], |
71
|
|
|
|
|
|
|
schema => { withRevisions => { type => 'boolean' }, withData => {type=>'boolean' }}, |
72
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ], |
73
|
|
|
|
|
|
|
}, |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
checksum => { |
77
|
|
|
|
|
|
|
rest => [ get => '{{database}}_api/collection/{name}/checksum' ], |
78
|
|
|
|
|
|
|
schema => { withRevisions => { type => 'boolean' }, withData => {type=>'boolean' }}, |
79
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ], |
80
|
|
|
|
|
|
|
}, |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
set_properties => { |
83
|
|
|
|
|
|
|
rest => [ put => '{{database}}_api/collection/{name}/properties'], |
84
|
|
|
|
|
|
|
schema => { waitForSync => { type => 'boolean' }, journalSize => { type => 'integer' }}, |
85
|
|
|
|
|
|
|
inject_properties => [ 'database', 'name' ], |
86
|
|
|
|
|
|
|
}, |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _new { |
94
|
0
|
|
|
0
|
|
|
my ($class, %opts) = @_; |
95
|
0
|
|
|
|
|
|
return bless {%opts} => $class; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub bulk_import { |
99
|
0
|
|
|
0
|
1
|
|
my ($self, $documents, %options) = @_; |
100
|
0
|
|
0
|
|
|
|
$options{type} ||= "list"; |
101
|
|
|
|
|
|
|
return $self->{arango}->_api( bulk_import_list => { |
102
|
|
|
|
|
|
|
database => $self->{database}, |
103
|
|
|
|
|
|
|
collection => $self->{name}, |
104
|
0
|
|
|
|
|
|
_body => $documents, |
105
|
|
|
|
|
|
|
_url_parameters => \%options |
106
|
|
|
|
|
|
|
}) |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub document_paths { |
110
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
111
|
|
|
|
|
|
|
return $self->{arango}->_api( all_keys => { database => $self->{database}, collection => $self->{name}, type => "path"})->{result} |
112
|
0
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub create_document { |
115
|
0
|
|
|
0
|
1
|
|
my ($self, $body) = @_; |
116
|
0
|
0
|
|
|
|
|
die "Arango::Tango | Refusing to store undefined body" unless defined($body); |
117
|
0
|
|
|
|
|
|
return $self->{arango}->_api( create_document => { database => $self->{database}, collection => $self->{name}, _body => $body}) |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub replace_document { |
121
|
0
|
|
|
0
|
1
|
|
my ($self, $key, $body) = @_; |
122
|
0
|
0
|
|
|
|
|
die "Arango::Tango | Refusing to store undefined body" unless defined($body); |
123
|
0
|
|
|
|
|
|
return $self->{arango}->_api( replace_document => { database => $self->{database}, collection => $self->{name}, key => $key, _body => $body}) |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub get_access_level { |
127
|
0
|
|
|
0
|
1
|
|
my ($self, $username) = @_; |
128
|
0
|
|
|
|
|
|
return $self->{arango}->get_access_level( $username, $self->{database}, $self->{name} ); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub clear_access_level { |
132
|
0
|
|
|
0
|
1
|
|
my ($self, $username) = @_; |
133
|
0
|
|
|
|
|
|
return $self->{arango}->clear_access_level( $username , $self->{database}, $self->{name} ); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub set_access_level { |
137
|
0
|
|
|
0
|
1
|
|
my ($self, $username, $grant) = @_; |
138
|
0
|
|
|
|
|
|
return $self->{arango}->set_access_level($username, $grant, $self->{database}, $self->{name}); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__END__ |