MongoDB.pm

filter: Statementstmt 95.8% 46 / 48 Branchbran 50.0% 1 / 2 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 14 / 14 Podpod 100% 1 / 1 totaltotal 92.9% 66 / 71 CC 3 SCAR 3.2
CC
3
Cov
93%
connect
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« MongoDB/_Types.pm ↑ Summary MongoDB/InsertManyResult.pm »
1 # Copyright 2009 - present MongoDB, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14  
15 59 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 59 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 59 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 package MongoDB;
20 # ABSTRACT: Official MongoDB Driver for Perl (EOL)
21  
22 59 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 59 our $VERSION = 'v2.2.2';
24  
25 # regexp_pattern was unavailable before 5.10, had to be exported to load the
26 # function implementation on 5.10, and was automatically available in 5.10.1
27 59 ▶use if ($] eq '5.010000'), 're', 'regexp_pattern';
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 59 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
30 59 ▶use MongoDB::MongoClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 59 ▶use MongoDB::Database;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 59 ▶use MongoDB::Collection;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 59 ▶use MongoDB::BulkWrite;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 59 ▶use MongoDB::_Link;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 59 ▶use MongoDB::_Protocol;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 59 ▶use BSON::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 # regexp_pattern was unavailable before 5.10, had to be exported to load the
39 # function implementation on 5.10, and was automatically available in 5.10.1
40 59 ▶if ( $] eq '5.010' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] eq "5.010") 0 59 59
41 0 require re;
42 0 re->import('regexp_pattern');
43 }
44  
45 #pod =method connect
46 #pod
47 #pod $client = MongoDB->connect(); # localhost, port 27107
48 #pod $client = MongoDB->connect($host_uri);
49 #pod $client = MongoDB->connect($host_uri, $options);
50 #pod
51 #pod This function returns a L<MongoDB::MongoClient> object. The first parameter is
52 #pod used as the C<host> argument and must be a host name or L<connection string
53 #pod URI|MongoDB::MongoClient/CONNECTION STRING URI>. The second argument is
54 #pod optional. If provided, it must be a hash reference of constructor arguments
55 #pod for L<MongoDB::MongoClient::new|MongoDB::MongoClient/ATTRIBUTES>.
56 #pod
57 #pod If an error occurs, a L<MongoDB::Error> object will be thrown.
58 #pod
59 #pod B<NOTE>: To connect to a replica set, a replica set name must be provided.
60 #pod For example, if the set name is C<"setA">:
61 #pod
62 #pod $client = MongoDB->connect("mongodb://example.com/?replicaSet=setA");
63 #pod
64 #pod =cut
65  
66 114 ▶sub connect {
Subroutine connect: called CC=3 SCAR=11.0
Pod documented
67 114 my ($class, $host, $options) = @_;
68 114 ▶ $host ||= "mongodb://localhost";
Condition50%1/2
$host ||= "mongodb://localhost"
l!l
1140
MC/DC0%0/1
$host ||= "mongodb://localhost"
$host
Truth table50%1/2
A
A= $host
Aresult
11
00
69 114 ▶ $options ||= {};
Condition100%2/2
$options ||= {}
l!l
7242
MC/DC100%1/1
$options ||= {}
$options
Truth table100%2/2
A
A= $options
Aresult
11
00
70 114 $options->{host} = $host;
71 114 return MongoDB::MongoClient->new( $options );
72 }
73  
74 59 1;
75  
76 =pod
77  
78 =encoding UTF-8
79  
80 =head1 NAME
81  
82 MongoDB - Official MongoDB Driver for Perl (EOL)
83  
84 =head1 VERSION
85  
86 version v2.2.2
87  
88 =head1 END OF LIFE NOTICE
89  
90 Version v2.2.0 was the final feature release of the MongoDB Perl driver and
91 version v2.2.2 is the final patch release.
92  
93 B<As of August 13, 2020, the MongoDB Perl driver and related libraries have
94 reached end of life and are no longer supported by MongoDB.> See the
95 L<August 2019 deprecation
96 notice|https://www.mongodb.com/blog/post/the-mongodb-perl-driver-is-being-deprecated>
97 for rationale.
98  
99 If members of the community wish to continue development, they are welcome
100 to fork the code under the terms of the Apache 2 license and release it
101 under a new namespace. Specifications and test files for MongoDB drivers
102 and libraries are published in an open repository:
103 L<mongodb/specifications|https://github.com/mongodb/specifications/tree/master/source>.
104  
105 =head1 SYNOPSIS
106  
107 use MongoDB;
108  
109 my $client = MongoDB->connect('mongodb://localhost');
110 my $collection = $client->ns('foo.bar'); # database foo, collection bar
111 my $result = $collection->insert_one({ some => 'data' });
112 my $data = $collection->find_one({ _id => $result->inserted_id });
113  
114 =head1 DESCRIPTION
115  
116 This is the official Perl driver for L<MongoDB|http://www.mongodb.com>.
117 MongoDB is an open-source document database that provides high performance,
118 high availability, and easy scalability.
119  
120 A MongoDB server (or multi-server deployment) hosts a number of databases. A
121 database holds a set of collections. A collection holds a set of documents. A
122 document is a set of key-value pairs. Documents have dynamic schema. Using dynamic
123 schema means that documents in the same collection do not need to have the same
124 set of fields or structure, and common fields in a collection's documents may
125 hold different types of data.
126  
127 Here are some resources for learning more about MongoDB:
128  
129 =over 4
130  
131 =item *
132  
133 L<MongoDB Manual|http://docs.mongodb.org/manual/contents/>
134  
135 =item *
136  
137 L<MongoDB CRUD Introduction|http://docs.mongodb.org/manual/core/crud-introduction/>
138  
139 =item *
140  
141 L<MongoDB Data Modeling Introductions|http://docs.mongodb.org/manual/core/data-modeling-introduction/>
142  
143 =back
144  
145 To get started with the Perl driver, see these pages:
146  
147 =over 4
148  
149 =item *
150  
151 L<MongoDB Perl Driver Tutorial|MongoDB::Tutorial>
152  
153 =item *
154  
155 L<MongoDB Perl Driver Examples|MongoDB::Examples>
156  
157 =back
158  
159 Extensive documentation and support resources are available via the
160 L<MongoDB community website|http://www.mongodb.org/>.
161  
162 =head1 USAGE
163  
164 The MongoDB driver is organized into a set of classes representing
165 different levels of abstraction and functionality.
166  
167 As a user, you first create and configure a L<MongoDB::MongoClient> object
168 to connect to a MongoDB deployment. From that client object, you can get a
169 L<MongoDB::Database> object for interacting with a specific database.
170  
171 From a database object, you can get a L<MongoDB::Collection> object for
172 CRUD operations on that specific collection, or a L<MongoDB::GridFSBucket>
173 object for working with an abstract file system hosted on the database.
174 Each of those classes may return other objects for specific features or
175 functions.
176  
177 See the documentation of those classes for more details or the
178 L<MongoDB Perl Driver Tutorial|MongoDB::Tutorial> for an example.
179  
180 L<MongoDB::ClientSession> objects are generated from a
181 L<MongoDB::MongoClient> and allow for advanced consistency options, like
182 causal-consistency and transactions.
183  
184 =head2 Error handling
185  
186 Unless otherwise documented, errors result in fatal exceptions. See
187 L<MongoDB::Error> for a list of exception classes and error code
188 constants.
189  
190 =head1 METHODS
191  
192 =head2 connect
193  
194 $client = MongoDB->connect(); # localhost, port 27107
195 $client = MongoDB->connect($host_uri);
196 $client = MongoDB->connect($host_uri, $options);
197  
198 This function returns a L<MongoDB::MongoClient> object. The first parameter is
199 used as the C<host> argument and must be a host name or L<connection string
200 URI|MongoDB::MongoClient/CONNECTION STRING URI>. The second argument is
201 optional. If provided, it must be a hash reference of constructor arguments
202 for L<MongoDB::MongoClient::new|MongoDB::MongoClient/ATTRIBUTES>.
203  
204 If an error occurs, a L<MongoDB::Error> object will be thrown.
205  
206 B<NOTE>: To connect to a replica set, a replica set name must be provided.
207 For example, if the set name is C<"setA">:
208  
209 $client = MongoDB->connect("mongodb://example.com/?replicaSet=setA");
210  
211 =begin Pod::Coverage
212  
213  
214  
215  
216 =end Pod::Coverage
217  
218 =head1 SUPPORTED MONGODB VERSIONS
219  
220 The driver has been tested against MongoDB versions 2.6 through 4.2. All
221 features of these versions are supported, except for field-level
222 encryption. The driver may work with future versions of MongoDB, but will
223 not include support for new MongoDB features and should be B<thoroughly
224 tested> within applications before deployment.
225  
226 =head1 SEMANTIC VERSIONING SCHEME
227  
228 Starting with MongoDB C<v1.0.0>, the driver reverts to the more familiar
229 three-part version-tuple numbering scheme used by both Perl and MongoDB:
230 C<vX.Y.Z>
231  
232 =over 4
233  
234 =item *
235  
236 C<X> will be incremented for incompatible API changes.
237  
238 =item *
239  
240 Even-value increments of C<Y> indicate stable releases with new functionality. C<Z> will be incremented for bug fixes.
241  
242 =item *
243  
244 Odd-value increments of C<Y> indicate unstable ("development") releases that should not be used in production. C<Z> increments have no semantic meaning; they indicate only successive development releases.
245  
246 =back
247  
248 See the Changes file included with releases for an indication of the nature of
249 changes involved.
250  
251 =head1 ENVIRONMENT VARIABLES
252  
253 If the C<PERL_MONGO_WITH_ASSERTS> environment variable is true before the
254 MongoDB module is loaded, then its various classes will be generated with
255 internal type assertions enabled. This has a severe performance cost and
256 is not recommended for production use. It may be useful in diagnosing
257 bugs.
258  
259 If the C<PERL_MONGO_NO_DEP_WARNINGS> environment variable is true, then
260 deprecated methods will not issue warnings when used. (Normally, a
261 deprecation warning is issued once per call-site for deprecated methods.)
262  
263 =head1 THREADS
264  
265 Per L<threads> documentation, use of Perl threads is discouraged by the
266 maintainers of Perl and the MongoDB Perl driver does not test or provide support
267 for use with threads.
268  
269 =head1 AUTHORS
270  
271 =over 4
272  
273 =item *
274  
275 David Golden <david@mongodb.com>
276  
277 =item *
278  
279 Rassi <rassi@mongodb.com>
280  
281 =item *
282  
283 Mike Friedman <friedo@friedo.com>
284  
285 =item *
286  
287 Kristina Chodorow <k.chodorow@gmail.com>
288  
289 =item *
290  
291 Florian Ragwitz <rafl@debian.org>
292  
293 =back
294  
295 =head1 CONTRIBUTORS
296  
297 =for stopwords Andrew Page Andrey Khozov Ashley Willis Ask Bjørn Hansen Bernard Gorman Brendan W. McAdams Brian Moss Casey Rojas Christian Sturm Walde Colin Cyr Danny Raetzsch David Morrison Nadle Steinbrunner Storch diegok D. Ilmari Mannsåker Eric Daniels Finn Kempers (Shadowcat Systems Ltd) Gerard Goossen Glenn Fowler Graham Barr Hao Wu Harish Upadhyayula Jason Carey Toffaletti Johann Rolschewski John A. Kunze Joseph Harnish Josh Matthews Joshua Juran J. Stewart Kamil Slowikowski Ken Williams Matthew Shopsin Matt S Trout Michael Langner Rotmanov Mike Dirolf Mohammad Anwar Nickola Trupcheff Nigel Gregoire Niko Tyni Nuno Carvalho Orlando Vazquez Othello Maurer Pan Fan Pavel Denisov Rahul Dhodapkar Robert Sedlacek Robin Lee Roman Yerin Ronald J Kimball Ryan Chipman Slaven Rezic Stephen Oberholtzer Steve Sanbeg Stuart Watt Thomas Bloor Tobias Leich Uwe Voelker Wallace Reis Wan Bachtiar Whitney Jackson Xavier Guimard Xtreak Zhihong Zhang
298  
299 =over 4
300  
301 =item *
302  
303 Andrew Page <andrew@infosiftr.com>
304  
305 =item *
306  
307 Andrey Khozov <avkhozov@gmail.com>
308  
309 =item *
310  
311 Ashley Willis <ashleyw@cpan.org>
312  
313 =item *
314  
315 Ask Bjørn Hansen <ask@develooper.com>
316  
317 =item *
318  
319 Bernard Gorman <bernard.gorman@mongodb.com>
320  
321 =item *
322  
323 Brendan W. McAdams <brendan@mongodb.com>
324  
325 =item *
326  
327 Brian Moss <kallimachos@gmail.com>
328  
329 =item *
330  
331 Casey Rojas <casey.j.rojas@gmail.com>
332  
333 =item *
334  
335 Christian Hansen <chansen@cpan.org>
336  
337 =item *
338  
339 Christian Sturm <kind@gmx.at>
340  
341 =item *
342  
343 Christian Walde <walde.christian@googlemail.com>
344  
345 =item *
346  
347 Colin Cyr <ccyr@sailingyyc.com>
348  
349 =item *
350  
351 Danny Raetzsch <danny@paperskymedia.com>
352  
353 =item *
354  
355 David Morrison <dmorrison@venda.com>
356  
357 =item *
358  
359 David Nadle <david@nadle.com>
360  
361 =item *
362  
363 David Steinbrunner <dsteinbrunner@pobox.com>
364  
365 =item *
366  
367 David Storch <david.storch@mongodb.com>
368  
369 =item *
370  
371 diegok <diego@freekeylabs.com>
372  
373 =item *
374  
375 D. Ilmari Mannsåker <ilmari.mannsaker@net-a-porter.com>
376  
377 =item *
378  
379 Eric Daniels <eric.daniels@mongodb.com>
380  
381 =item *
382  
383 Finn Kempers (Shadowcat Systems Ltd) <toyou1995@gmail.com>
384  
385 =item *
386  
387 Gerard Goossen <gerard@ggoossen.net>
388  
389 =item *
390  
391 Glenn Fowler <cebjyre@cpan.org>
392  
393 =item *
394  
395 Graham Barr <gbarr@pobox.com>
396  
397 =item *
398  
399 Hao Wu <echowuhao@gmail.com>
400  
401 =item *
402  
403 Harish Upadhyayula <hupadhyayula@dealersocket.com>
404  
405 =item *
406  
407 Jason Carey <jason.carey@mongodb.com>
408  
409 =item *
410  
411 Jason Toffaletti <jason@topsy.com>
412  
413 =item *
414  
415 Johann Rolschewski <rolschewski@gmail.com>
416  
417 =item *
418  
419 John A. Kunze <jak@ucop.edu>
420  
421 =item *
422  
423 Joseph Harnish <bigjoe1008@gmail.com>
424  
425 =item *
426  
427 Josh Matthews <joshua.matthews@mongodb.com>
428  
429 =item *
430  
431 Joshua Juran <jjuran@metamage.com>
432  
433 =item *
434  
435 J. Stewart <jstewart@langley.theshire>
436  
437 =item *
438  
439 Kamil Slowikowski <kslowikowski@gmail.com>
440  
441 =item *
442  
443 Ken Williams <kwilliams@cpan.org>
444  
445 =item *
446  
447 Matthew Shopsin <matt.shopsin@mongodb.com>
448  
449 =item *
450  
451 Matt S Trout <mst@shadowcat.co.uk>
452  
453 =item *
454  
455 Michael Langner <langner@fch.de>
456  
457 =item *
458  
459 Michael Rotmanov <rotmanov@sipgate.de>
460  
461 =item *
462  
463 Mike Dirolf <mike@mongodb.com>
464  
465 =item *
466  
467 Mohammad S Anwar <mohammad.anwar@yahoo.com>
468  
469 =item *
470  
471 Nickola Trupcheff <n.trupcheff@gmail.com>
472  
473 =item *
474  
475 Nigel Gregoire <nigelg@airg.com>
476  
477 =item *
478  
479 Niko Tyni <ntyni@debian.org>
480  
481 =item *
482  
483 Nuno Carvalho <mestre.smash@gmail.com>
484  
485 =item *
486  
487 Orlando Vazquez <ovazquez@gmail.com>
488  
489 =item *
490  
491 Othello Maurer <omaurer@venda.com>
492  
493 =item *
494  
495 Pan Fan <nightsailer@gmail.com>
496  
497 =item *
498  
499 Pavel Denisov <pavel.a.denisov@gmail.com>
500  
501 =item *
502  
503 Rahul Dhodapkar <rahul@mongodb.com>
504  
505 =item *
506  
507 Robert Sedlacek (Shadowcat Systems Ltd) <phaylon@cpan.org>
508  
509 =item *
510  
511 Robin Lee <cheeselee@fedoraproject.org>
512  
513 =item *
514  
515 Roman Yerin <kid@cpan.org>
516  
517 =item *
518  
519 Ronald J Kimball <rkimball@pangeamedia.com>
520  
521 =item *
522  
523 Ryan Chipman <ryan@ryanchipman.com>
524  
525 =item *
526  
527 Slaven Rezic <slaven.rezic@idealo.de>
528  
529 =item *
530  
531 Slaven Rezic <srezic@cpan.org>
532  
533 =item *
534  
535 Stephen Oberholtzer <stevie@qrpff.net>
536  
537 =item *
538  
539 Steve Sanbeg <stevesanbeg@buzzfeed.com>
540  
541 =item *
542  
543 Stuart Watt <stuart@morungos.com>
544  
545 =item *
546  
547 Thomas Bloor (Shadowcat Systems Ltd) <tbsliver@cpan.org>
548  
549 =item *
550  
551 Tobias Leich <email@froggs.de>
552  
553 =item *
554  
555 Uwe Voelker <uwe.voelker@xing.com>
556  
557 =item *
558  
559 Wallace Reis <wallace@reis.me>
560  
561 =item *
562  
563 Wan Bachtiar <sindbach@gmail.com>
564  
565 =item *
566  
567 Whitney Jackson <whjackson@gmail.com>
568  
569 =item *
570  
571 Xavier Guimard <x.guimard@free.fr>
572  
573 =item *
574  
575 Xtreak <tirkarthi@users.noreply.github.com>
576  
577 =item *
578  
579 Zhihong Zhang <zzh_621@yahoo.com>
580  
581 =back
582  
583 =head1 COPYRIGHT AND LICENSE
584  
585 This software is Copyright (c) 2020 by MongoDB, Inc.
586  
587 This is free software, licensed under:
588  
589 The Apache License, Version 2.0, January 2004
590  
591 =cut
592  
593 __END__
« MongoDB/_Types.pm ↑ Summary MongoDB/InsertManyResult.pm »