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