NAME

Dancer::Plugin::Mongoose - Mongoose interface for Dancer applications

VERSION

version 0.00002

SYNOPSIS

# Dancer Code File
use Dancer;
use Dancer::Plugin::Mongoose;

get '/profile/:id' => sub {
    my $user = schema->users->find_one(params->{id});
    
    # or explicitly ask for a schema by name:
    $user = schema('foo')->users->find_one(params->{id});
    template user_profile => { user => $user };
};

dance;

# Dancer Configuration File (minimumal settings)
plugins:
  DBIC:
    foo:
      class:  "Foo::Bar"

Database connection details are read from your Dancer application config - see below.

DESCRIPTION

This plugin provides an easy way to obtain Mongoose derived class instances via the the function schema(), which it automatically imports. You just need to point to a class in your Dancer configuration file.

CONFIGURATION

Connection details will be grabbed from your Dancer config file. For example:

plugins:
  Mongoose:
    foo:
      class: Foo
      database:
        db_name: "one"
        host: "mongodb://localhost:27017"
    bar:
      class: Foo::Bar
      database: "two"
    baz:
      class: Foo::Baz
      database:
        db_name: "three"
        host: "mongodb://elsewhere:27017"
        query_timeout: 60

Each schema configuration *must* have a class option. If the host option is omitted it is assumed that it is hard-coded in the class or that localhost should be used. The host option should be the MongoDB driver connection string.

The class option provided should be a proper Perl package name that Dancer::Plugin::Mongoose will use as a Mongoose derived class.

AUTHOR

Al Newkirk <awncorp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 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.