1MongoDB(3) User Contributed Perl Documentation MongoDB(3)
2
3
4
6 MongoDB - Official MongoDB Driver for Perl (EOL)
7
9 version v2.2.2
10
12 Version v2.2.0 was the final feature release of the MongoDB Perl driver
13 and version v2.2.2 is the final patch release.
14
15 As of August 13, 2020, the MongoDB Perl driver and related libraries
16 have reached end of life and are no longer supported by MongoDB. See
17 the August 2019 deprecation notice
18 <https://www.mongodb.com/blog/post/the-mongodb-perl-driver-is-being-
19 deprecated> for rationale.
20
21 If members of the community wish to continue development, they are
22 welcome to fork the code under the terms of the Apache 2 license and
23 release it under a new namespace. Specifications and test files for
24 MongoDB drivers and libraries are published in an open repository:
25 mongodb/specifications
26 <https://github.com/mongodb/specifications/tree/master/source>.
27
29 use MongoDB;
30
31 my $client = MongoDB->connect('mongodb://localhost');
32 my $collection = $client->ns('foo.bar'); # database foo, collection bar
33 my $result = $collection->insert_one({ some => 'data' });
34 my $data = $collection->find_one({ _id => $result->inserted_id });
35
37 This is the official Perl driver for MongoDB <http://www.mongodb.com>.
38 MongoDB is an open-source document database that provides high
39 performance, high availability, and easy scalability.
40
41 A MongoDB server (or multi-server deployment) hosts a number of
42 databases. A database holds a set of collections. A collection holds a
43 set of documents. A document is a set of key-value pairs. Documents
44 have dynamic schema. Using dynamic schema means that documents in the
45 same collection do not need to have the same set of fields or
46 structure, and common fields in a collection's documents may hold
47 different types of data.
48
49 Here are some resources for learning more about MongoDB:
50
51 • MongoDB Manual <http://docs.mongodb.org/manual/contents/>
52
53 • MongoDB CRUD Introduction
54 <http://docs.mongodb.org/manual/core/crud-introduction/>
55
56 • MongoDB Data Modeling Introductions
57 <http://docs.mongodb.org/manual/core/data-modeling-introduction/>
58
59 To get started with the Perl driver, see these pages:
60
61 • MongoDB Perl Driver Tutorial
62
63 • MongoDB Perl Driver Examples
64
65 Extensive documentation and support resources are available via the
66 MongoDB community website <http://www.mongodb.org/>.
67
69 The MongoDB driver is organized into a set of classes representing
70 different levels of abstraction and functionality.
71
72 As a user, you first create and configure a MongoDB::MongoClient object
73 to connect to a MongoDB deployment. From that client object, you can
74 get a MongoDB::Database object for interacting with a specific
75 database.
76
77 From a database object, you can get a MongoDB::Collection object for
78 CRUD operations on that specific collection, or a MongoDB::GridFSBucket
79 object for working with an abstract file system hosted on the database.
80 Each of those classes may return other objects for specific features or
81 functions.
82
83 See the documentation of those classes for more details or the MongoDB
84 Perl Driver Tutorial for an example.
85
86 MongoDB::ClientSession objects are generated from a
87 MongoDB::MongoClient and allow for advanced consistency options, like
88 causal-consistency and transactions.
89
90 Error handling
91 Unless otherwise documented, errors result in fatal exceptions. See
92 MongoDB::Error for a list of exception classes and error code
93 constants.
94
96 connect
97 $client = MongoDB->connect(); # localhost, port 27107
98 $client = MongoDB->connect($host_uri);
99 $client = MongoDB->connect($host_uri, $options);
100
101 This function returns a MongoDB::MongoClient object. The first
102 parameter is used as the "host" argument and must be a host name or
103 connection string URI. The second argument is optional. If provided,
104 it must be a hash reference of constructor arguments for
105 MongoDB::MongoClient::new.
106
107 If an error occurs, a MongoDB::Error object will be thrown.
108
109 NOTE: To connect to a replica set, a replica set name must be provided.
110 For example, if the set name is "setA":
111
112 $client = MongoDB->connect("mongodb://example.com/?replicaSet=setA");
113
115 The driver has been tested against MongoDB versions 2.6 through 4.2.
116 All features of these versions are supported, except for field-level
117 encryption. The driver may work with future versions of MongoDB, but
118 will not include support for new MongoDB features and should be
119 thoroughly tested within applications before deployment.
120
122 Starting with MongoDB "v1.0.0", the driver reverts to the more familiar
123 three-part version-tuple numbering scheme used by both Perl and
124 MongoDB: "vX.Y.Z"
125
126 • "X" will be incremented for incompatible API changes.
127
128 • Even-value increments of "Y" indicate stable releases with new
129 functionality. "Z" will be incremented for bug fixes.
130
131 • Odd-value increments of "Y" indicate unstable ("development")
132 releases that should not be used in production. "Z" increments
133 have no semantic meaning; they indicate only successive development
134 releases.
135
136 See the Changes file included with releases for an indication of the
137 nature of changes involved.
138
140 If the "PERL_MONGO_WITH_ASSERTS" environment variable is true before
141 the MongoDB module is loaded, then its various classes will be
142 generated with internal type assertions enabled. This has a severe
143 performance cost and is not recommended for production use. It may be
144 useful in diagnosing bugs.
145
146 If the "PERL_MONGO_NO_DEP_WARNINGS" environment variable is true, then
147 deprecated methods will not issue warnings when used. (Normally, a
148 deprecation warning is issued once per call-site for deprecated
149 methods.)
150
152 Per threads documentation, use of Perl threads is discouraged by the
153 maintainers of Perl and the MongoDB Perl driver does not test or
154 provide support for use with threads.
155
157 • David Golden <david@mongodb.com>
158
159 • Rassi <rassi@mongodb.com>
160
161 • Mike Friedman <friedo@friedo.com>
162
163 • Kristina Chodorow <k.chodorow@gmail.com>
164
165 • Florian Ragwitz <rafl@debian.org>
166
168 • Andrew Page <andrew@infosiftr.com>
169
170 • Andrey Khozov <avkhozov@gmail.com>
171
172 • Ashley Willis <ashleyw@cpan.org>
173
174 • Ask Bjørn Hansen <ask@develooper.com>
175
176 • Bernard Gorman <bernard.gorman@mongodb.com>
177
178 • Brendan W. McAdams <brendan@mongodb.com>
179
180 • Brian Moss <kallimachos@gmail.com>
181
182 • Casey Rojas <casey.j.rojas@gmail.com>
183
184 • Christian Hansen <chansen@cpan.org>
185
186 • Christian Sturm <kind@gmx.at>
187
188 • Christian Walde <walde.christian@googlemail.com>
189
190 • Colin Cyr <ccyr@sailingyyc.com>
191
192 • Danny Raetzsch <danny@paperskymedia.com>
193
194 • David Morrison <dmorrison@venda.com>
195
196 • David Nadle <david@nadle.com>
197
198 • David Steinbrunner <dsteinbrunner@pobox.com>
199
200 • David Storch <david.storch@mongodb.com>
201
202 • diegok <diego@freekeylabs.com>
203
204 • D. Ilmari Mannsåker <ilmari.mannsaker@net-a-porter.com>
205
206 • Eric Daniels <eric.daniels@mongodb.com>
207
208 • Finn Kempers (Shadowcat Systems Ltd) <toyou1995@gmail.com>
209
210 • Gerard Goossen <gerard@ggoossen.net>
211
212 • Glenn Fowler <cebjyre@cpan.org>
213
214 • Graham Barr <gbarr@pobox.com>
215
216 • Hao Wu <echowuhao@gmail.com>
217
218 • Harish Upadhyayula <hupadhyayula@dealersocket.com>
219
220 • Jason Carey <jason.carey@mongodb.com>
221
222 • Jason Toffaletti <jason@topsy.com>
223
224 • Johann Rolschewski <rolschewski@gmail.com>
225
226 • John A. Kunze <jak@ucop.edu>
227
228 • Joseph Harnish <bigjoe1008@gmail.com>
229
230 • Josh Matthews <joshua.matthews@mongodb.com>
231
232 • Joshua Juran <jjuran@metamage.com>
233
234 • J. Stewart <jstewart@langley.theshire>
235
236 • Kamil Slowikowski <kslowikowski@gmail.com>
237
238 • Ken Williams <kwilliams@cpan.org>
239
240 • Matthew Shopsin <matt.shopsin@mongodb.com>
241
242 • Matt S Trout <mst@shadowcat.co.uk>
243
244 • Michael Langner <langner@fch.de>
245
246 • Michael Rotmanov <rotmanov@sipgate.de>
247
248 • Mike Dirolf <mike@mongodb.com>
249
250 • Mohammad S Anwar <mohammad.anwar@yahoo.com>
251
252 • Nickola Trupcheff <n.trupcheff@gmail.com>
253
254 • Nigel Gregoire <nigelg@airg.com>
255
256 • Niko Tyni <ntyni@debian.org>
257
258 • Nuno Carvalho <mestre.smash@gmail.com>
259
260 • Orlando Vazquez <ovazquez@gmail.com>
261
262 • Othello Maurer <omaurer@venda.com>
263
264 • Pan Fan <nightsailer@gmail.com>
265
266 • Pavel Denisov <pavel.a.denisov@gmail.com>
267
268 • Rahul Dhodapkar <rahul@mongodb.com>
269
270 • Robert Sedlacek (Shadowcat Systems Ltd) <phaylon@cpan.org>
271
272 • Robin Lee <cheeselee@fedoraproject.org>
273
274 • Roman Yerin <kid@cpan.org>
275
276 • Ronald J Kimball <rkimball@pangeamedia.com>
277
278 • Ryan Chipman <ryan@ryanchipman.com>
279
280 • Slaven Rezic <slaven.rezic@idealo.de>
281
282 • Slaven Rezic <srezic@cpan.org>
283
284 • Stephen Oberholtzer <stevie@qrpff.net>
285
286 • Steve Sanbeg <stevesanbeg@buzzfeed.com>
287
288 • Stuart Watt <stuart@morungos.com>
289
290 • Thomas Bloor (Shadowcat Systems Ltd) <tbsliver@cpan.org>
291
292 • Tobias Leich <email@froggs.de>
293
294 • Uwe Voelker <uwe.voelker@xing.com>
295
296 • Wallace Reis <wallace@reis.me>
297
298 • Wan Bachtiar <sindbach@gmail.com>
299
300 • Whitney Jackson <whjackson@gmail.com>
301
302 • Xavier Guimard <x.guimard@free.fr>
303
304 • Xtreak <tirkarthi@users.noreply.github.com>
305
306 • Zhihong Zhang <zzh_621@yahoo.com>
307
309 This software is Copyright (c) 2020 by MongoDB, Inc.
310
311 This is free software, licensed under:
312
313 The Apache License, Version 2.0, January 2004
314
315
316
317perl v5.34.0 2021-07-22 MongoDB(3)