Yancy::Backend::Dbic - A backend for DBIx::Class schemas
version 0.012
# yancy.conf { backend => 'dbic://My::Schema/dbi:Pg:localhost', collections => { ResultSet => { ... }, }, } # Plugin use Mojolicious::Lite; plugin Yancy => { backend => 'dbic://My::Schema/dbi:Pg:localhost', collections => { ResultSet => { ... }, }, };
This Yancy backend allows you to connect to a DBIx::Class schema to manage the data inside.
See Yancy::Backend for the methods this backend has and their return values.
The URL for this backend takes the form dbic://<schema_class>/<dbi_dsn> where schema_class is the DBIx::Class schema module name and dbi_dsn is the full DBI data source name (DSN) used to connect to the database.
dbic://<schema_class>/<dbi_dsn>
schema_class
dbi_dsn
The collections for this backend are the names of the DBIx::Class::Row classes in your schema, just as DBIx::Class allows in the $schema->resultset method.
$schema->resultset
So, if you have the following schema:
package My::Schema; use base 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces; package My::Schema::Result::People; __PACKAGE__->table( 'people' ); __PACKAGE__->add_columns( qw/ id name email / ); package My::Schema::Result::Business __PACKAGE__->table( 'business' ); __PACKAGE__->add_columns( qw/ id name email / );
You could map that schema to the following collections:
{ backend => 'dbic://My::Schema/dbi:SQLite:test.db', collections => { People => { properties => { id => { type => 'integer', readOnly => 1, }, name => { type => 'string' }, email => { type => 'string' }, }, }, Business => { properties => { id => { type => 'integer', readOnly => 1, }, name => { type => 'string' }, email => { type => 'string' }, }, }, }, }
Yancy::Backend, DBIx::Class, Yancy
Doug Bell <preaction@cpan.org>
This software is copyright (c) 2017 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.
To install Yancy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Yancy
CPAN shell
perl -MCPAN -e shell install Yancy
For more information on module installation, please visit the detailed CPAN module installation guide.