MongoDB - Official MongoDB Driver for Perl


version v0.704.1.0


    use MongoDB;

    my $client     = MongoDB::MongoClient->new(host => 'localhost', port => 27017);
    my $database   = $client->get_database( 'foo' );
    my $collection = $database->get_collection( 'bar' );
    my $id         = $collection->insert({ some => 'data' });
    my $data       = $collection->find_one({ _id => $id });


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 cluster) 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.


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 server (or cluster). 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.


The following low-level functions are deprecated and will be removed in a future release.

  • write_insert

  • write_query

  • write_update

  • write_remove

  • read_documents


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.


  • David Golden <>

  • Mike Friedman <>

  • Kristina Chodorow <>

  • Florian Ragwitz <>


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

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004