The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MongoDB - Official MongoDB Driver for Perl

VERSION

version v1.1.0

NOTE: The v1.1.x versions are development releases in advance of the MongoDB Perl Driver v1.2.0. They are available for evaluation and testing and should not be used in production. Most notably, they include support for features in MongoDB 3.2 release candidates.

SYNOPSIS

    use MongoDB;

    my $client     = MongoDB->connect('mongodb://localhost');
    my $collection = $client->ns('foo.bar'); # database foo, collection bar
    my $result     = $collection->insert_one({ some => 'data' });
    my $data       = $collection->find_one({ _id => $result->inserted_id });

DESCRIPTION

This is the official Perl driver for MongoDB. MongoDB is an open-source document database that provides high performance, high availability, and easy scalability.

A MongoDB server (or multi-server deployment) hosts a number of databases. A database holds a set of collections. A collection holds a set of documents. A document is a set of key-value pairs. Documents have dynamic schema. Using dynamic schema means that documents in the same collection do not need to have the same set of fields or structure, and common fields in a collection's documents may hold different types of data.

Here are some resources for learning more about MongoDB:

To get started with the Perl driver, see these pages:

Extensive documentation and support resources are available via the MongoDB community website.

USAGE

The MongoDB driver is organized into a set of classes representing different levels of abstraction and functionality.

As a user, you first create and configure a MongoDB::MongoClient object to connect to a MongoDB deployment. From that client object, you can get a MongoDB::Database object for interacting with a specific database.

From a database object, you can get a MongoDB::Collection object for CRUD operations on that specific collection, or a MongoDB::GridFS object for working with an abstract file system hosted on the database. Each of those classes may return other objects for specific features or functions.

See the documentation of those classes for more details or the MongoDB Perl Driver Tutorial for an example.

Error handling

Unless otherwise documented, errors result in fatal exceptions. See MongoDB::Error for a list of exception classes and error code constants.

METHODS

connect

    $client = MongoDB->connect(); # localhost, port 27107
    $client = MongoDB->connect($host_uri);
    $client = MongoDB->connect($host_uri, $options);

This function returns a MongoDB::MongoClient object. The first parameter is used as the host argument and must be a host name or connection string URI. The second argument is optional. If provided, it must be a hash reference of constructor arguments for MongoDB::MongoClient::new.

If an error occurs, a MongoDB::Error object will be thrown.

NOTE: To connect to a replica set, a replica set name must be provided. For example, if the set name is "setA":

    $client = MongoDB->connect("mongodb://example.com/?replicaSet=setA");

SEMANTIC VERSIONING SCHEME

Starting with MongoDB v1.0.0, the driver reverts to the more familiar three-part version-tuple numbering scheme used by both Perl and MongoDB: vX.Y.Z

  • X will be incremented for incompatible API changes.

  • Even-value increments of Y indicate stable releases with new functionality. Z will be incremented for bug fixes.

  • Odd-value increments of Y indicate unstable ("development") releases that should not be used in production. Z increments have no semantic meaning; they indicate only successive development releases.

See the Changes file included with releases for an indication of the nature of changes involved.

ENVIRONMENT VARIABLES

If the PERL_MONGO_WITH_ASSERTS environment variable is true before the MongoDB module is loaded, then its various classes will be generated with internal type assertions enabled. This has a severe performance cost and is not recommended for production use. It may be useful in diagnosing bugs.

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://jira.mongodb.org/browse/PERL. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license. https://github.com/mongodb/mongo-perl-driver

  git clone https://github.com/mongodb/mongo-perl-driver.git

AUTHORS

  • David Golden <david@mongodb.com>

  • Mike Friedman <friedo@friedo.com>

  • Kristina Chodorow <k.chodorow@gmail.com>

  • Florian Ragwitz <rafl@debian.org>

CONTRIBUTORS

  • Andrew Page <andrew@infosiftr.com>

  • Andrey Khozov <avkhozov@gmail.com>

  • Ashley Willis <ashleyw@cpan.org>

  • Ask Bjørn Hansen <ask@develooper.com>

  • Bernard Gorman <bernard.gorman@mongodb.com>

  • Brendan W. McAdams <brendan@mongodb.com>

  • Casey Rojas <casey.j.rojas@gmail.com>

  • Christian Hansen <chansen@cpan.org>

  • Christian Sturm <kind@gmx.at>

  • Christian Walde <walde.christian@googlemail.com>

  • Colin Cyr <ccyr@sailingyyc.com>

  • Danny Raetzsch <danny@paperskymedia.com>

  • David Morrison <dmorrison@venda.com>

  • David Nadle <david@nadle.com>

  • David Steinbrunner <dsteinbrunner@pobox.com>

  • David Storch <david.storch@mongodb.com>

  • D. Ilmari Mannsåker <ilmari.mannsaker@net-a-porter.com>

  • Eric Daniels <eric.daniels@mongodb.com>

  • Gerard Goossen <gerard@ggoossen.net>

  • Glenn Fowler <cebjyre@cpan.org>

  • Graham Barr <gbarr@pobox.com>

  • Hao Wu <echowuhao@gmail.com>

  • Jason Carey <jason.carey@mongodb.com>

  • Jason Toffaletti <jason@topsy.com>

  • Johann Rolschewski <rolschewski@gmail.com>

  • Joseph Harnish <bigjoe1008@gmail.com>

  • Josh Matthews <joshua.matthews@mongodb.com>

  • Joshua Juran <jjuran@metamage.com>

  • J. Stewart <jstewart@langley.theshire>

  • Kamil Slowikowski <kslowikowski@gmail.com>

  • Ken Williams <kwilliams@cpan.org>

  • Matthew Shopsin <matt.shopsin@mongodb.com>

  • Michael Langner <langner@fch.de>

  • Michael Rotmanov <rotmanov@sipgate.de>

  • Mike Dirolf <mike@mongodb.com>

  • Nickola Trupcheff <n.trupcheff@gmail.com>

  • Niko Tyni <ntyni@debian.org>

  • Nuno Carvalho <mestre.smash@gmail.com>

  • Orlando Vazquez <ovazquez@gmail.com>

  • Othello Maurer <omaurer@venda.com>

  • Pan Fan <nightsailer@gmail.com>

  • Rahul Dhodapkar <rahul@mongodb.com>

  • Robin Lee <cheeselee@fedoraproject.org>

  • Roman Yerin <kid@cpan.org>

  • Ronald J Kimball <rkimball@pangeamedia.com>

  • Ryan Chipman <ryan@ryanchipman.com>

  • Stephen Oberholtzer <stevie@qrpff.net>

  • Steve Sanbeg <stevesanbeg@buzzfeed.com>

  • Stuart Watt <stuart@morungos.com>

  • Uwe Voelker <uwe.voelker@xing.com>

  • Whitney Jackson <whjackson@gmail.com>

  • Xtreak <tirkarthi@users.noreply.github.com>

  • Zhihong Zhang <zzh_621@yahoo.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by MongoDB, Inc..

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004