Dancer::Plugin::Mongo - MongoDB plugin for the Dancer micro framework
version 0.03
use Dancer; use Dancer::Plugin::Mongo; get '/widget/view/:id' => sub { my $widget = mongo->database->collection->find_one({ id => params->{id} }); }
Dancer::Plugin::Mongo provides a wrapper around MongoDB. Add the appropriate configuraton options to your config.yml and then you can access a MongoDB database using the 'mongo' keyword.
To query the database, use the standard MongoDB syntax, described in MongoDB::Collection.
Connection details will be taken from your Dancer application config file, and should be specified as follows:
plugins: Mongo: host: port: username: password: w: wtimeout: auto_reconnect: auto_connect: timeout: db_name: query_timeout: find_master:
All these configuration values are optional, full details are in the MongoDB::Connection documentation.
Adam Taylor <ajct@cpan.org>
This software is copyright (c) 2010 by Adam Taylor.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Dancer::Plugin::Mongo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer::Plugin::Mongo
CPAN shell
perl -MCPAN -e shell install Dancer::Plugin::Mongo
For more information on module installation, please visit the detailed CPAN module installation guide.