Mojo::DB::Role::DBIx::Class - A Mojo role connecting DBIx::Class to Mojo::Pg and Mojo::SQLite
use Mojo::SQLite; $\ = "\n"; $, = "\t"; my $sql = Mojo::SQLite->new; my $db = $sql->db; $db = $db->with_roles('Mojo::DB::Role::DBIx::Class'); my $rs = $db->resultset('SomeTable')->search({ some_field => 'some_value' }) print for $db->dbic->sources
This module adds a dbic method loading a DBIx::Class on top of an existing Mojo::Pg or Mojo::SQLite database
dbic
Connects the database via the schema either with a schema class passed as the parameter:
$db->dbic('My::Schema')
or with a schema class passed as "class" option:
$db->dbic({ class => 'My::Schema' })
or without any schema - in which case DBIx::Class::Schema::Loader gets used
$db->dbic($opts)
All other options get passed on to the class being connected.
Returns the DBIx::Class::Schema so that it can be used like this
print for $db->dbic->sources; my $rs = $db->dbic->resultset('SomeTable')->search({ some_field => 'some_value' })
resultset
Shortcut for $db->dbic->resultset
my $rs = $db->resultset('SomeTable')->search({ some_field => 'some_value' })
This software is copyright (c) 2021 by Simone Cesano.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DBIx::Class, DBIx::Class::Schema::Loader, Mojo::Pg, Mojo::SQLite
Simone Cesano
To install Mojo::DB::Role::DBIx::Class, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::DB::Role::DBIx::Class
CPAN shell
perl -MCPAN -e shell install Mojo::DB::Role::DBIx::Class
For more information on module installation, please visit the detailed CPAN module installation guide.