https://github.com/preaction/mojolicious-plugin-dbic
Mojolicious ❤️ DBIx::Class
https://github.com/preaction/mojolicious-plugin-dbic
Last synced: 4 months ago
JSON representation
Mojolicious ❤️ DBIx::Class
- Host: GitHub
- URL: https://github.com/preaction/mojolicious-plugin-dbic
- Owner: preaction
- License: other
- Created: 2018-12-02T23:20:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-01T22:57:40.000Z (almost 5 years ago)
- Last Synced: 2025-04-09T20:43:19.509Z (about 1 year ago)
- Language: Perl
- Size: 44.9 KB
- Stars: 2
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkdn
- Changelog: CHANGES
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/preaction/Mojolicious-Plugin-DBIC)
[](https://coveralls.io/r/preaction/Mojolicious-Plugin-DBIC?branch=master)
# 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 ) {
<%= $row->id %>
% }
# DESCRIPTION
This plugin makes working with [DBIx::Class](https://metacpan.org/pod/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](https://metacpan.org/pod/Mojolicious::Plugin::DBIC::Controller::DBIC).
# SEE ALSO
[Mojolicious](https://metacpan.org/pod/Mojolicious), [DBIx::Class](https://metacpan.org/pod/DBIx::Class), [Yancy](https://metacpan.org/pod/Yancy)
# AUTHOR
Doug Bell
# CONTRIBUTOR
K. Andrew Parker
# 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.