++ed by:
BEROV KEEDI ARPI MHOWARD ASB

10 PAUSE users
1 non-PAUSE user.

💯 Doug Bell
and 3 contributors

NAME

Yancy::Backend::Dbic - A backend for DBIx::Class schemas

VERSION

version 1.007

SYNOPSIS

    ### URL string
    use Mojolicious::Lite;
    plugin Yancy => {
        backend => 'dbic://My::Schema/dbi:Pg:localhost',
        read_schema => 1,
    };

    ### DBIx::Class::Schema object
    use Mojolicious::Lite;
    use My::Schema;
    plugin Yancy => {
        backend => { Dbic => My::Schema->connect( 'dbi:SQLite:myapp.db' ) },
        read_schema => 1,
    };

    ### Arrayref
    use Mojolicious::Lite;
    use My::Schema;
    plugin Yancy => {
        backend => {
            Dbic => [
                'My::Schema',
                'dbi:SQLite:mysql.db',
                undef, undef,
                { PrintError => 1 },
            ],
        },
        read_schema => 1,
    };

DESCRIPTION

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.

Backend URL

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.

Collections

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.

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' },
                },
            },
        },
    }

SEE ALSO

Yancy::Backend, DBIx::Class, Yancy

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.