NAME
XAS::Model::Database - A class to load database schemas
SYNOPSIS
use XAS::Model::Schema;
use XAS::Model::Database
schema => 'ETL::Model::Database',
table => 'Master';
try {
$schema = XAS::Model::Schema->opendb('database');
my @rows = Master->search($schema);
foreach my $row (@rows) {
printf("Hostname = %s\n", $row->Hostname);
}
} catch {
my $ex = $_;
print $ex;
};
DESCRIPTION
This module loads DBIx::Class table definitions and defines a path for the database.ini configuration file. It can also load shortcut constants for table definations.
Example
use XAS::Model::Database
schema => 'ETL::Model::Database',
table => 'Master'
;
or
use XAS::Model::Database
schema => 'ETL::Model::Database',
tables => qw( Master Detail )
;
or
use XAS::Model::Database
schema => 'ETL::Model::Database',
table => ':all'
;
The difference is that in the first example you are only loading the "Master" constant into your module. The second example loads the constants "Master" and "Detail". The ":all" qualifier would load all the defined constants.
HOOKS
The following hooks are defined to load table definitions and define constants. The order that they are called is important, i.e. 'schema' must come before 'table'.
schema
This defines a load path to the modules that defines a database schema. DBIx::Class loads modules based on the path. For example all modules below 'ETL::Model::Database' will be loaded at once. You can be more specific. If you only want the 'Progress' database schema you can load it by using 'ETL::Model::Database::Progress'.
table
This will define a constant for a table definition. This constant is based on the table name, which is defined by the modules name. So the module 'ETL::Model::Database::Progress::ActOther' will have a constant named 'ActOther' that refers to the module.
WARNING
If you have multiple tables named the same thing in differant schemas
and load all the schemas at once, this constant will refer to the last
loaded table definition.
tables
Does the same thing as 'table'.
SEE ALSO
AUTHOR
Kevin L. Esteb, <kevin@kesteb.us>
COPYRIGHT AND LICENSE
Copyright (c) 2012-2015 Kevin L. Esteb
This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.