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