| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ABSTRACT: MongoDB v2 driver in Mojolicious |
|
2
|
1
|
|
|
1
|
|
87170
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
61
|
|
|
4
|
|
|
|
|
|
|
package Mojolicious::Plugin::Mongodbv2; |
|
5
|
|
|
|
|
|
|
$Mojolicious::Plugin::Mongodbv2::VERSION = '0.01'; |
|
6
|
1
|
|
|
1
|
|
572
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
|
1
|
|
|
|
|
200596
|
|
|
|
1
|
|
|
|
|
7
|
|
|
7
|
1
|
|
|
1
|
|
1580
|
use MongoDB; |
|
|
1
|
|
|
|
|
1594406
|
|
|
|
1
|
|
|
|
|
246
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
|
10
|
0
|
|
|
0
|
1
|
|
my ($self, $app, $conf) = @_; |
|
11
|
0
|
|
0
|
|
|
|
$conf = $conf || {}; |
|
12
|
|
|
|
|
|
|
|
|
13
|
0
|
|
0
|
|
|
|
$conf->{helper} ||= 'db'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$app->attr('mongodb_connection' => sub { |
|
16
|
0
|
|
|
0
|
|
|
my $m = Mojolicious::Plugin::Mongodbv2::Client->new(conf => $conf); |
|
17
|
0
|
|
|
|
|
|
$m->init(); |
|
18
|
0
|
|
|
|
|
|
return $m->_client; |
|
19
|
0
|
|
|
|
|
|
}); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$app->helper($conf->{helper} => sub { |
|
22
|
0
|
|
|
0
|
|
|
my $s = shift; |
|
23
|
0
|
|
|
|
|
|
my $m = $s->app->mongodb_connection; |
|
24
|
0
|
|
|
|
|
|
return $m->db($m->db_name); |
|
25
|
0
|
|
|
|
|
|
}); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package Mojolicious::Plugin::Mongodbv2::Client; |
|
29
|
|
|
|
|
|
|
$Mojolicious::Plugin::Mongodbv2::Client::VERSION = '0.01'; |
|
30
|
1
|
|
|
1
|
|
11
|
use Mojo::Base -base; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
10
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'conf' => sub { {host => 'mongodb://localhost:27017/mongodbv2' } }; |
|
33
|
|
|
|
|
|
|
has '_client'; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub init { |
|
36
|
0
|
|
|
0
|
|
|
my $s = shift; |
|
37
|
0
|
|
|
|
|
|
$s->_client(MongoDB::MongoClient->new($s->conf)); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=encoding UTF-8 |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Mojolicious::Plugin::Mongodbv2 - MongoDB v2 driver in Mojolicious |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 VERSION |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
version 0.01 |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 AUTHOR |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Emiliano Bruni |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Emiliano Bruni. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
63
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |