The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
NAME
    Dancer::Plugin::ORMesque - Light ORM for Dancer

VERSION
    version 1.113100

SYNOPSIS
    Dancer::Plugin::ORMesque is a lightweight ORM for Dancer supporting
    SQLite, MySQL, PostgreSQL and more making it a great alternative to
    Dancer::Plugin::Database if you are looking for a bit more automation
    and a fair alternative to Dancer::Plugin::DBIC when you don't have the
    time, need or desire to learn Dancer::Plugin::DBIC and DBIx::Class.
    Dancer::Plugin::ORMesque is an object relational mapper for Dancer based
    on the ORMesque module using SQL::Abstract querying syntax.

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

        plugins:
          ORMesque:
            connection_name:
              dsn:  "dbi:SQLite:dbname=./foo.db"

        # Use the db() keyword to establish a new connection to the database then
        # access your tables as follows:
        
    my $user = db->users;
        
    # Grab the first record, not neccessary if operating on only one record
        
    $user->read;
        
    # SQL::Abstract where clause passed to the "read" method
        
    $user->read({
            'column' => 'query'
        });
        
    $user->first;
        $user->last;
        
    # How many records in collection
        
    $user->count
        
    for (0..$user->count) {
            print $user->column;
            $user->column('new stuff');
            $user->update($user->current, $user->id);
            $user->next;
        }
        
    # The database objects main accessors are CRUD (create, read, update, and delete)
        
    $user->create;
          $user->read;
            $user->update;
              $user->delete;
        
    # Also, need direct access to the resultset?
        
    $user->collection; # returns an array of hashrefs
        $user->current;    # return a hashref of the current row in the collection
        
    # The db() method/keyword instantiates a new Dancer::Plugin::ORMesque instance
        # which uses the datasource configuration details in your configuration file
        # to create database objects and accessors.
        
    my $db = db();

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

        plugins:
          ORMesque:
            foo:
              dsn: dbi:SQLite:dbname=./foo.db
            bar:
              schema_class: MyApp::Model
              dsn:  dbi:mysql:db_foo
              user: root
              pass: secret
              options:
                RaiseError: 1
                PrintError: 1

    Each schema configuration *must* have a dsn option. The dsn option
    should be the DBI driver connection string. All other options are
    optional.

    If a schema_class option is not provided, then ORMesque will auto load
    the schema based on the database tables and columns.

    The schema_class option, if provided, should be a proper Perl package
    name that Dancer::Plugin::ORMesque will use as a class.

    Optionally, a database configuation may have user, pass and options
    paramters as described in the documentation for connect() in DBI.

        # Note! You can also declare your connection information with the
        # following syntax:
        plugings:
          ORMesque:
            foo:
              connect_info:
                - dbi:mysql:db_foo
                - root
                - secret
                -
                  RaiseError: 1
                  PrintError: 1

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.