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