GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Teng::Schema::Declare(3) User Contributed Perl Documentation Teng::Schema::Declare(3)

Teng::Schema::Declare - DSL For Declaring Teng Schema

    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
    };

    use Teng::Schema::Declare;
    my $schema = schema {
        table {
            name "your_table_name";
            columns qw( col1 col2 col3 );
        };
    } "MyDB::Schema";

"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
"base_row_class"
Specify the default base row class with Teng::Schema::Declare.

Default value is Teng::Row.

This option is useful when you adds features for My::DB::Row class.

"default_row_class_prefix"
Specify the default prefix of row class.

"row_class" of each table definition has priority over "default_row_class_prefix".

e.g.:

    use Teng::Schema::Declare;
    my $schema = schema {
        default_row_class_prefix 'My::Entity';
        table {
            name 'user';
            column qw(name);
        };
    };
    $schema->get_row_class('user'); # => My::Entity::User
    

Default value is determined by the schema class.

e.g.:

    package My::DB::Schema;
    use Teng::Schema::Declare;
    table {
        name 'user';
        column qw(name);
    };

    __PACKAGE__->instance->get_row_class('user'); # => My::DB::Row::User
    1;
    
2020-03-25 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.