NAME

MongoDB - Official MongoDB Driver for Perl

VERSION

version v0.999.998.5

This is the Alpha 4 release for v1.0.0.0.

ALPHA RELEASE NOTICE AND ROADMAP

The v0.999.998.x releases are alpha releases towards v1.0.0.0. While they are believed be as reliable as the stable release series, the implementation and API are still subject to change. While preserving back-compatibility is important and will be delivered to a great extent, it will not be guaranteed.

Using the v0.999.998.x series means that you understand that your code may break due to changes in the driver between now and the v1.0.0.0 stable release.

This Alpha 4 release includes these major changes:

  • MongoDB::Collection now offers a new CRUD API. All MongoDB drivers are converging on a common CRUD API, with similar names, signatures and options. The legacy methods are now deprecated.

  • MongoDB::GridFS now respect the default read preference and write concern of the MongoDB::Database object (possibly inherited from MongoDB::MongoClient). This means that all GridFS operations now default to acknowledged mode, just like collection operations have been doing since v0.502.0 in 2012.

  • All collection and database operations throw MongoDB::Error exceptions if an error condition occurs.

More details on changes and how to upgrade applications may be found in MongoDB::Upgrading.

Roadmap

Subsequent alphas will be released periodically. The v1.0.0.0 release is expected in the middle of 2015.

Some expected (but not guaranteed) changes in future releases include:

  • A new API for manipulating indexes. Like the new CRUD API, this will be standard across MongoDB drivers.

  • Some existing options and methods will be deprecated to improve consistency and clarity of what remains.

  • Documentation will be significantly revised.

In order to avoid holding up v1.0.0.0, the following changes will be deferred until after the v1.0.0.0 release:

  • The driver will become pure-Perl capable, using the Moo framework instead of Moose. This will significantly reduce the size of the total dependency tree.

  • BSON encoding will be extracted to a separate module, with both pure-Perl and C variants available.

  • Transformation of Perl data structures to/from BSON will become more customizable.

SYNOPSIS

use MongoDB;

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

# long-hand
my $client     = MongoDB::MongoClient->new(host => 'mongodb://localhost');
my $database   = $client->get_database( 'foo' );
my $collection = $database->get_collection( 'bar' );

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. 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:

For getting 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.

SEMANTIC VERSIONING SCHEME

Starting with MongoDB v0.704.0.0, the driver will be using a modified semantic versioning scheme.

Versions will have a vX.Y.Z.N tuple scheme with the following properties:

  • X will be incremented for incompatible API changes

  • Y will be incremented for new functionality that is backwards compatible

  • Z will be incremented for backwards-compatible bug fixes

  • N will be zero for a stable release; N will be non-zero for development releases

We use N because CPAN does not support pre-release version labels (e.g. "-alpha1") and requires non-decreasing version numbers for releases.

When N is non-zero, X, Y, and Z have no semantic meaning except to indicate the last stable release.

For example, v0.704.0.1 is merely the first development release after v0.704.0.0. The next stable release could be a bug fix (v0.704.1.0), a feature enhancement (v0.705.0.0), or an API change (v1.0.0.0).

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

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@mongodb.com>

  • Kristina Chodorow <kristina@mongodb.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>

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

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

  • Christian Sturm <kind@gmx.at>

  • Colin Cyr <ccyr@sailingyyc.com>

  • danny <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>

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

  • Jason Toffaletti <jason@topsy.com>

  • Johann Rolschewski <rolschewski@gmail.com>

  • Joseph Harnish <bigjoe1008@gmail.com>

  • Joshua Juran <jjuran@metamage.com>

  • J. Stewart <jstewart@langley.theshire>

  • Kamil Slowikowski <kslowikowski@gmail.com>

  • Ken Williams <kwilliams@cpan.org>

  • mapbuh <n.trupcheff@gmail.com>

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

  • Michael Langner <langner@fch.de>

  • Michael Rotmanov <rotmanov@sipgate.de>

  • Mike Dirolf <mike@mongodb.com>

  • nightlord <zzh_621@yahoo.com>

  • nightsailer <nightsailer@gmail.com>

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

  • Orlando Vazquez <ovazquez@gmail.com>

  • Othello Maurer <omaurer@venda.com>

  • Robin Lee <cheeselee@fedoraproject.org>

  • Roman Yerin <kid@cpan.org>

  • Ronald J Kimball <rkimball@pangeamedia.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>

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