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

Dancer::Plugin::MongoDB - MongoDB connections as provided by Mango.

STATUS

Horribly under-tested, may induce seizures and sudden death. You have been warned. Additionally, this module will require MongoDB 2.6+. This is primarily because Mango requires it. You will get an error "MongoDB wire protocol version 2 required" if this is not the case.

VERSION

version 0.35

SYNOPSIS

    use Dancer;
    use Dancer::Plugin::MongoDB;

    get '/widget/view/:id' => sub {
        my $mg = mongo('mongoa');
        my $db = $mg->database('foo');
        my $cl = $db->collection('bar');
        my $curs = $cl->find({ this => param('id') });

        ..
    }

    # or

    get '/widget/view/:id' => sub {
        my $mg = mongo('mongoa')->database('foo')->collection('bar')->find({ this => param('id') });

        ..
    }

DESCRIPTION

Dancer::Plugin::MongoDB implements the "Mango" driver from the Mojolicious team. It also uses some of the connection pooling features that the Dancer::Plugin::Database module implements. For the most part, read the Mango documentation for full implementation.

CONFIGURATON

Connection details will be taken from your Dancer application config file, and should be specified as follows:

    plugins:
        MongoDB:
            host: "myhost"
            port: 27017
            db_name: "mydb"
            username: "myuser"
            password: "mypass"
            w: 1
            wtimeout: 1000
            credentials:
                [ mydb, myuser, mypass]
                [ myotherdb, myotheruser, myotherpass]

or:

    plugin:
        MongoDB:
            connections:
                foohost:
                    host: "foohost"
                    port: 27017
                    db_name: "mydb"
                barhost:
                    host: "barhost"
                    port: 27017

The attribute names are verbatim to the attribute names in Mango.

ACKNOWLEDGEMENTS

Thanks to Adam Taylor for the original Dancer::Plugin::Mongo. Thanks to the Dancer team for creating a product that keeps me gainfully employed. Thanks to the Mojolicious team for Mango.

This module is HEAVILY reliant on the original Dancer::Plugin::Database code. Most parts in here are unceremoniously copy-pasted from their code. Thanks guys for the work you're doing!

AUTHOR

Tyler Hardison <tyler@seraph-net.net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Tyler Hardison.

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