| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catmandu::Store::CouchDB; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1362
|
use Catmandu::Sane; |
|
|
1
|
|
|
|
|
105316
|
|
|
|
1
|
|
|
|
|
8
|
|
|
4
|
1
|
|
|
1
|
|
324
|
use Moo; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
6
|
|
|
5
|
1
|
|
|
1
|
|
1054
|
use Catmandu::Store::CouchDB::Bag; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
32
|
|
|
6
|
1
|
|
|
1
|
|
985
|
use Store::CouchDB; |
|
|
1
|
|
|
|
|
1790301
|
|
|
|
1
|
|
|
|
|
351
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'Catmandu::Store'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Catmandu::Store::CouchDB - A searchable store backed by CouchDB |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
A searchable store backed by CouchDB. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Version 0.01 |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Catmandu::Store::CouchDB; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $store = Catmandu::Store::CouchDB->new; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $obj1 = $store->bag->add({ name => 'Patrick' }); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
printf "obj1 stored as %s\n" , $obj1->{_id}; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Force an id in the store |
|
37
|
|
|
|
|
|
|
my $obj2 = $store->bag->add({ _id => 'test123' , name => 'Nicolas' }); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $obj3 = $store->bag->get('test123'); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$store->bag->delete('test123'); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$store->bag->delete_all; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# All bags are iterators |
|
46
|
|
|
|
|
|
|
$store->bag->each(sub { ... }); |
|
47
|
|
|
|
|
|
|
$store->bag->take(10)->each(sub { ... }); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 new(host => 'localhost', port => '5984', ...) |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Create a new Catmandu::Store::CouchDB store. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 bag($name) |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Create or retieve a bag with name $name. Returns a Catmandu::Bag. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $CLIENT_ARGS = [qw( |
|
62
|
|
|
|
|
|
|
debug |
|
63
|
|
|
|
|
|
|
host |
|
64
|
|
|
|
|
|
|
port |
|
65
|
|
|
|
|
|
|
ssl |
|
66
|
|
|
|
|
|
|
user |
|
67
|
|
|
|
|
|
|
pass |
|
68
|
|
|
|
|
|
|
)]; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has couch_db => (is => 'ro', lazy => 1, builder => '_build_couch_db'); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _build_couch_db { |
|
73
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
74
|
0
|
|
|
|
|
|
my $db = Store::CouchDB->new; |
|
75
|
0
|
|
|
|
|
|
$db->config(delete $self->{_args}); |
|
76
|
0
|
|
|
|
|
|
$db; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub BUILD { |
|
80
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
|
81
|
0
|
|
|
|
|
|
$self->{_args} = {}; |
|
82
|
0
|
|
|
|
|
|
for my $key (@$CLIENT_ARGS) { |
|
83
|
0
|
0
|
|
|
|
|
$self->{_args}{$key} = $args->{$key} if exists $args->{$key}; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Nicolas Steenlant, C<< >> |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
98
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
99
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |