NAME

Mojolicious::Plugin::DBIC - Mojolicious ♥ DBIx::Class

VERSION

version 0.005

SYNOPSIS

use Mojolicious::Lite;
plugin DBIC => {
    schema => { 'Local::Schema' => 'dbi:SQLite::memory:' },
};
get '/model', {
    controller => 'DBIC',
    action => 'list',
    resultset => 'Model',
    template => 'model/list.html.ep',
};
app->start;
__DATA__
@@ model/list.html.ep
% for my $row ( $resultset->all ) {
    <p><%= $row->id %></p>
% }

DESCRIPTION

This plugin makes working with DBIx::Class easier in Mojolicious.

Configuration

Configure your schema in multiple ways:

# Just DSN
plugin DBIC => {
    schema => {
        'MySchema' => 'DSN',
    },
};

# Arguments to connect()
plugin DBIC => {
    schema => {
        'MySchema' => [ 'DSN', 'user', 'password', { RaiseError => 1 } ],
    },
};

# Connected schema object
my $schema = MySchema->connect( ... );
plugin DBIC => {
    schema => $schema,
};

This plugin can also be configured from the application configuration file:

# myapp.conf
{
    dbic => {
        schema => {
            'MySchema' => 'dbi:SQLite:data.db',
        },
    },
}

# myapp.pl
use Mojolicious::Lite;
plugin 'Config';
plugin 'DBIC';

Controller

This plugin contains a controller to reduce the code needed for simple database operations. See Mojolicious::Plugin::DBIC::Controller::DBIC.

SEE ALSO

Mojolicious, DBIx::Class, Yancy

AUTHOR

Doug Bell <preaction@cpan.org>

CONTRIBUTOR

K. Andrew Parker <kparker@citytech.cuny.edu>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Doug Bell.

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