NAME
Mojolicious::Plugin::DBIC::Controller::DBIC - Build simple views to DBIC data
VERSION
version 0.002
SYNOPSIS
use Mojolicious::Lite;
plugin DBIC => { schema => ... };
get '/', {
controller => 'DBIC',
action => 'list',
resultset => 'BlogPosts',
template => 'blog/list',
};
DESCRIPTION
This controller allows for easy working with data from the schema. Controllers are configured through the stash when setting up the routes.
METHODS
list
get '/', {
controller => 'DBIC',
action => 'list',
resultset => 'BlogPosts',
template => 'blog/list',
};
List data in a ResultSet. Returns false if it has rendered a response, true if dispatch can continue.
This method uses the following stash values for configuration:
- resultset
-
The DBIx::Class::ResultSet class to list.
This method sets the following stash values for template rendering:
- resultset
-
The DBIx::Class::ResultSet object containing the desired objects.
get
get '/blog/:id', {
controller => 'DBIC',
action => 'get',
resultset => 'BlogPosts',
template => 'blog/get',
};
Fetch a single result by its ID. If no result is found, renders a not found error. Returns false if it has rendered a response, true if dispatch can continue.
This method uses the following stash values for configuration:
- resultset
-
The DBIx::Class::ResultSet class to use.
- id
-
The ID to pass to "find" in DBIx::Class::ResultSet.
This method sets the following stash values for template rendering:
- row
-
The DBIx::Class::Row object containing the desired object.
SEE ALSO
AUTHOR
Doug Bell <preaction@cpan.org>
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.