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

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

STATUS

Tested in a production environment. It's a good idea to read the documentation for Mango as it's async. Which means you must be ready to handle this. In most of my code I'm using the loop function to wait for the server response. However, for inserts, I'm not waiting at all. Handy.

VERSION

version 0.41

SYNOPSIS

    use Dancer;
    use Dancer::Plugin::Mango;

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

        ..
    }

    # or

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

        ..
    }

DESCRIPTION

Dancer::Plugin::Mango 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:
        Mango:
            host: "myhost"
            port: 27017
            db_name: "mydb"
            username: "myuser"
            password: "mypass"
            w: 1
            wtimeout: 1000
            credentials:
                [ mydb, myuser, mypass]
                [ myotherdb, myotheruser, myotherpass]

or:

    plugin:
        Mango:
            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>

CONTRIBUTORS

Collin Seaton cseaton <at> cpan <dot> org

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.