DBIx-QuickORM

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    $orm = orm('my_orm');.

    See DBIx::QuickORM::Handle for more details on handles, which are
    similar to ResultSets from DBIx::Class.

RECIPES

 DEFINE DB LATER

    In some cases you may want to define your orm/schema before you have
    your database credentials. Then you want to add the database later in
    an app/script bootstrap process.

    Schema:

        package My::Schema;
        use DBIx::QuickORM;
    
        orm MyORM => sub {
            autofill;
        };

README  view on Meta::CPAN


          db mydb => sub {
              pass 'hunter2'; # Do not store any real passwords in plaintext in code!!!!
          };

    creds sub { return \%CREDS }

      Allows you to provide a coderef that will return a hashref with all
      the necessary database connection fields.

      This is mainly useful if you credentials are in an encrypted YAML or
      JSON file and you have a method to decrypt and read it returning it
      as a hash.

          db mydb => sub {
              creds sub { ... };
          };

    connect sub { ... }

    connect \&connect

README  view on Meta::CPAN

      an attempt will be made to construct a DSN from other parameters, if
      they are available.

          db mydb => sub {
              dsn "dbi:Pg:dbname=foo";
          };

    server $NAME => sub { ... }

      Used to define a server with multiple databases. This is a way to
      avoid re-specifying credentials for each database you connect to.

      You can use db('server_name.db_name') to fetch the database.

      Basically this allows you to specify any database fields once in the
      server, then define any number of databases that inherit them.

      Example:

          server pg => sub {
              host 'pg.myapp.com';

README.md  view on Meta::CPAN

`my $orm = orm('my_orm');`.

See [DBIx::QuickORM::Handle](https://metacpan.org/pod/DBIx%3A%3AQuickORM%3A%3AHandle) for more details on handles, which are similar to
ResultSets from [DBIx::Class](https://metacpan.org/pod/DBIx%3A%3AClass).

# RECIPES

## DEFINE DB LATER

In some cases you may want to define your orm/schema before you have your
database credentials. Then you want to add the database later in an app/script
bootstrap process.

Schema:

    package My::Schema;
    use DBIx::QuickORM;

    orm MyORM => sub {
        autofill;
    };

README.md  view on Meta::CPAN


        db mydb => sub {
            pass 'hunter2'; # Do not store any real passwords in plaintext in code!!!!
        };

- `creds sub { return \%CREDS }`

    Allows you to provide a coderef that will return a hashref with all the
    necessary database connection fields.

    This is mainly useful if you credentials are in an encrypted YAML or JSON file
    and you have a method to decrypt and read it returning it as a hash.

        db mydb => sub {
            creds sub { ... };
        };

- `connect sub { ... }`
- `connect \&connect`

    Instead of providing all the other fields, you may specify a coderef that

README.md  view on Meta::CPAN

    attempt will be made to construct a DSN from other parameters, if they are
    available.

        db mydb => sub {
            dsn "dbi:Pg:dbname=foo";
        };

- `server $NAME => sub { ... }`

    Used to define a server with multiple databases. This is a way to avoid
    re-specifying credentials for each database you connect to.

    You can use `db('server_name.db_name')` to fetch the database.

    Basically this allows you to specify any database fields once in the server, then
    define any number of databases that inherit them.

    Example:

        server pg => sub {
            host 'pg.myapp.com';

lib/DBIx/QuickORM.pm  view on Meta::CPAN

C<< my $orm = orm('my_orm'); >>.

See L<DBIx::QuickORM::Handle> for more details on handles, which are similar to
ResultSets from L<DBIx::Class>.

=head1 RECIPES

=head2 DEFINE DB LATER

In some cases you may want to define your orm/schema before you have your
database credentials. Then you want to add the database later in an app/script
bootstrap process.

Schema:

    package My::Schema;
    use DBIx::QuickORM;

    orm MyORM => sub {
        autofill;
    };

lib/DBIx/QuickORM.pm  view on Meta::CPAN


    db mydb => sub {
        pass 'hunter2'; # Do not store any real passwords in plaintext in code!!!!
    };

=item C<creds sub { return \%CREDS }>

Allows you to provide a coderef that will return a hashref with all the
necessary database connection fields.

This is mainly useful if you credentials are in an encrypted YAML or JSON file
and you have a method to decrypt and read it returning it as a hash.

    db mydb => sub {
        creds sub { ... };
    };

=item C<connect sub { ... }>

=item C<connect \&connect>

lib/DBIx/QuickORM.pm  view on Meta::CPAN

attempt will be made to construct a DSN from other parameters, if they are
available.

    db mydb => sub {
        dsn "dbi:Pg:dbname=foo";
    };

=item C<< server $NAME => sub { ... } >>

Used to define a server with multiple databases. This is a way to avoid
re-specifying credentials for each database you connect to.

You can use C<< db('server_name.db_name') >> to fetch the database.

Basically this allows you to specify any database fields once in the server, then
define any number of databases that inherit them.

Example:

    server pg => sub {
        host 'pg.myapp.com';

t/interface.t  view on Meta::CPAN

        {
            name    => 'from_creds',
            user    => 'username',
            pass    => 'password',
            socket  => 'socketname',
            dialect => 'DBIx::QuickORM::Dialect::PostgreSQL',

            created  => T(),
            compiled => T(),
        },
        "Got credentials from subroutine",
    );

    schema deeptest => sub {
        row_class "ClassA";
        table foo => sub {
            row_class "ClassB";
            db_name 'foo1';
            column a => 'MyType';
            column b => \'VARCHAR(123)', 'string';
            column c => sub {



( run in 0.591 second using v1.01-cache-2.11-cpan-4d50c553e7e )