The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Nephia::Plugin::Teng - Simple ORMapper Plugin For Nephia

SYNOPSIS

    use Nephia plugins => [qw/Teng/];

    path '/person/:id' => sub {
        my $id = path_param('id');
        my $row = teng->lookup('person', { id => $id });
        return res { 404 } unless $row;

        return {
            id => $id,
            name => $row->get_column('name'),
            age => $row->get_column('age'),
        };
    };

Read row from person table in database in this code.

DESCRIPTION

configuration - configuration for Teng.

configuration file:

    'DBI' => {
        connect_info => ['dbi:SQLite:dbname=data.db'],
        teng_plugins => [qw/Lookup Pager/]
    },

The "connect_info" is connect information for DBI.

Enumerate in "plugins" option if you want load Teng plugins.

teng - Create Teng Object

"teng" DSL create the Teng Object.

database_do - load SQL before plackup.

In this example to create table before plackup.

in controller :

    database_do "CREATE TABLE IF NOT EXISTS person (id INTEGER, name TEXT, age INTEGER);"

    path '/' => sub {
        ...
    };

SEE ALSO

Nephia

Teng

LICENSE

Copyright (C) macopy.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

mackee <macopy123[attttt]gmai.com>

ichigotake