line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kelp::Module::MongoDB; |
2
|
1
|
|
|
1
|
|
31620
|
use Kelp::Base 'Kelp::Module'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
848
|
use MongoDB; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.000'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub build { |
8
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
9
|
|
|
|
|
|
|
my $mongodb = MongoDB::MongoClient->new(%args); |
10
|
|
|
|
|
|
|
$self->register( mongodb => $mongodb ); |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
1; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__END__ |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Kelp::Module::MongoDB - Use MongoDB within Kelp |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
L<Kelp::Module::MongoDB> is a L<Kelp> plugin. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
First ... |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# conf/config.pl |
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
modules => ['MongoDB'], |
32
|
|
|
|
|
|
|
modules_init => { |
33
|
|
|
|
|
|
|
MongoDB => { |
34
|
|
|
|
|
|
|
host => 'localhost', # example |
35
|
|
|
|
|
|
|
port => 27017, # example |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Then ... |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
package MyApp; |
43
|
|
|
|
|
|
|
use Kelp::Base 'Kelp'; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub some_route { |
46
|
|
|
|
|
|
|
my $self = shift; |
47
|
|
|
|
|
|
|
my $db = $self->mongodb->get_database('foodb'); |
48
|
|
|
|
|
|
|
my $collection = $db->get_collection('bar'); |
49
|
|
|
|
|
|
|
my $id = $collection->insert({some => 'data'}); |
50
|
|
|
|
|
|
|
my $data = $collection->find_one({_id => $id}); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This module registers only one method into the application: C<mongodb>. |
58
|
|
|
|
|
|
|
It is an instance of a L<MongoDB> class. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHOR |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Adam Stokes E<lt>adamjs@cpan.orgE<gt> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 COPYRIGHT |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Copyright 2013- Adam Stokes |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 LICENSE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Licensed under the same terms as Perl. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SEE ALSO |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
L<Kelp>. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |