The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

ObjectDB::Meta - meta object

SYNOPSIS

    ObjectDB::Meta->new(
        table          => 'book',
        columns        => [qw/id author_id title/],
        primary_key    => 'id',
        auto_increment => 'id',
        relationships  => {
            author => {
                type = 'many to one',
                class => 'MyAuthor',
                map   => {author_id => 'id'}
            }
        }
    );

DESCRIPTION

Meta object is used internally for describing the table schema.

Inheritance

The key feature is inheritance. You can inherit schema, add or remove columns, specify new relationships and so on.

    package Parent;
    use base 'MyDB';

    __PACKAGE__->schema(
        table       => 'parent',
        columns     => [qw/id title/],
        primary_key => 'id'
    );

    package Child;
    use base 'Parent';

    __PACKAGE__->schema->add_column('description');

Schema

table

Table name.

columns

Column names.

primary_key

Primary key.

auto_increment

Auto increment field. This field is updated as soon as object is created.

unique_keys

Unique keys.

relationships

Relationships.