Al Newkirk


MongoDBI - A proper ODM (Object-Document-Mapper) for MongoDB


version 0.0.1_01


    package CDDB;

    use MongoDBI;
    app {
        # shared mongodb connection
        database => {
            name => 'mongodbi_cddb',
            host => 'mongodb://localhost:27017'
        # load child doc classes
        classes => {
            self => 1 # loads CDDB::*
            load => ['Other::Namspace']
    package main ;
    use DateTime;
    my $cddb = CDDB->new;
    my $cds  = $cddb->class('Album'); # grabs CDDB::Album
    # find cds released during or after the year 2000
    my $year_2000 = DateTime->set(year => 2000, month => 1, day => 1);

    my $search $cds->search->where('released$gt' => $year_2000)->query;
    while (my $cd = $search->next) {
        print $cd->title, "\n";


MongoDBI is an Object-Document-Mapper (ODM) for MongoDB. It allows you to create Moose-based classes to interact with MongoDB databases. Born out of the frustration from waiting for someone else to create a proper MongoDB access layer, I decided to bite-the-bullet and try my hand at it.

At-a-glance, most will enjoy MongoDBI for its ability to easily model classes while leveraging the power of MongoDB's schemaless and expeditios document-based design, dynamic queries, and atomic modifier operations.

Also noteworthy is MongoDBI's ease-of-use, chainable search facilities, automated indexing, moose-integration (inheritance support, etc), lean document updates via dirty field tracking, and ability for each class to be configured to use a different database and connection, etc.

Note! This library is still in its infancy and subject to change. The POD (documentation) may also be lacking in certain areas, for additional insight you may examine the accompanying tests.

This class, MongoDBI, sub-classes MongoDBI::Application, please review that module for more usage information.


Al Newkirk <>


This software is copyright (c) 2011 by awncorp.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.