NAME
Teng::Schema::Declare - DSL For Declaring Teng Schema
NORMAL USE
package MyDB::Schema;
use strict;
use warnings;
use Teng::Schema::Declare;
table {
name "your_table_name";
pk "primary_key";
columns qw( col1 col2 col3 );
inflate 'col1' => sub {
my ($col_value) = @_;
return MyDB::Class->new(name => $col_value);
};
deflate 'col1' => sub {
my ($col_value) = @_;
return ref $col_value ? $col_value->name : $col_value;
};
row_class 'MyDB::Row'; # optional
};
INLINE DECLARATION
use Teng::Schema::Declare;
my $schema = schema {
table {
name "your_table_name";
columns qw( col1 col2 col3 );
};
} "MyDB::Schema";
METHODS
- schema
-
schema data creation wrapper.
- table
-
set table name
- pk
-
set primary key
- columns
-
set columns
- inflate_rule
-
set inflate rule
- row_namespace
-
create Row class namespace