| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ABSTRACT: ArangoDB Database object |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Arango::DB::Database; |
|
4
|
|
|
|
|
|
|
$Arango::DB::Database::VERSION = '0.006'; |
|
5
|
5
|
|
|
5
|
|
2012
|
use Arango::DB::Cursor; |
|
|
5
|
|
|
|
|
13
|
|
|
|
5
|
|
|
|
|
160
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
39
|
use warnings; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
143
|
|
|
8
|
5
|
|
|
5
|
|
27
|
use strict; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
1833
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _new { |
|
11
|
0
|
|
|
0
|
|
|
my ($class, %opts) = @_; |
|
12
|
0
|
|
|
|
|
|
return bless {%opts} => $class; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub collection { |
|
16
|
0
|
|
|
0
|
1
|
|
my ($self, $name) = @_; |
|
17
|
0
|
|
|
|
|
|
my @match = grep { $_->{name} eq $name } @{$self->list_collections}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
if (scalar(@match)) { |
|
19
|
0
|
|
|
|
|
|
return Arango::DB::Collection->_new(arango => $self->{arango}, database => $self->{name}, 'name' => $name); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
else { |
|
22
|
0
|
|
|
|
|
|
die "Arango::DB | Collection not found in database $self->{name}." |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub cursor { |
|
27
|
0
|
|
|
0
|
1
|
|
my ($self, $aql, %opts) = @_; |
|
28
|
0
|
|
|
|
|
|
return Arango::DB::Cursor->_new(arango => $self->{arango}, database => $self->{name}, query => $aql, %opts); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub list_collections { |
|
32
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
33
|
0
|
|
|
|
|
|
return $self->{arango}->list_collections($self->{name}); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub create_collection { |
|
37
|
0
|
|
|
0
|
1
|
|
my ($self, $name) = @_; |
|
38
|
0
|
0
|
|
|
|
|
die "Arango::DB | Cannot create collection with empty collection or database name" unless length $name; |
|
39
|
0
|
|
|
|
|
|
return $self->{arango}->_api('create_collection', { database => $self->{name}, name => $name }) |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub delete_collection { |
|
43
|
0
|
|
|
0
|
1
|
|
my ($self, $name) = @_; |
|
44
|
0
|
0
|
|
|
|
|
die "Arango::DB | Cannot create collection with empty collection or database name" unless length $name; |
|
45
|
0
|
|
|
|
|
|
return $self->{arango}->_api('delete_collection', { database => $self->{name}, name => $name }) |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |