NAME

Plack::App::RapidApp::rDbic - Instant database CRUD using RapidApp

SYNOPSIS

use Plack::App::RapidApp::rDbic;

$app = Plack::App::RapidApp::rDbic->new({
  connect_info => {
    dsn      => 'dbi:SQLite:my_sqlt.db',
    user     => '',
    password => ''
  }
})->to_app;

# Or, for an existing schema class:
$app = Plack::App::RapidApp::rDbic->new({
  schema_class => 'My::Schema',
  connect_info => {
    dsn      => 'dbi:SQLite:my_sqlt.db',
    user     => '',
    password => ''
  }
})->to_app;

# For an existing schema connection:
my $schema = My::Schema->connect('dbi:SQLite:my_sqlt.db');
$app = Plack::App::RapidApp::rDbic->new({
  schema => $schema
})->to_app;

DESCRIPTION

This module provides a Plack interface to a runtime-generated database CRUD application. It bootstraps and loads a fully working RapidApp application with a RapidDbic configuration for an arbitrary database, which can be supplied as either an existing DBIx::Class::Schema or a simple DBI connect string (dsn) to have DBIx::Class schema classes generated for you.

This module is used internally by rdbic.pl which exposes only a portion of the available options as a command-line script.

CONFIGURATION

connect_info

Your connect_info args normalized to hashref form (with dsn/user/password.) See "connect_info" in DBIx::Class::Storage::DBI for more info on the hashref form of "connect_info".

dsn

Alternative way to supply connect_info, as a string. The database user and password can be optionally inlined using commas.

For example:

dsn => 'dbi:mysql:mydb,dbuser,dbpass'

Is equivelent to:

connect_info => ['dbi:mysql:mydb','dbuser','dbpass']

Is equivelent to:

connect_info => {
  dsn      => 'dbi:mysql:mydb',
  user     => 'dbuser',
  password => 'dbpass'
}

schema_class

Optional existing DBIx::Class::Schema class name. Leave unconfigured to have the schema classes generated on-the-fly using DBIx::Class::Schema::Loader.

schema

Optional alternative existing/connected schema object. This option can be used instead of connect_info/schema_class.

app_namespace

Name of the generated RapidApp/Catalyst app. Defaults to rDbicApp. When multiple instances are loaded, subsequent names are generated as rDbicApp1, rDbicApp2 and so on.

crud_profile

One of five choices to broadly control CRUD interface behavior:

editable

Default

Full CRUD is enabled with 'persist_immediately' turned off globally which means the user has to click "Save" to apply queued-up changes

edit-instant

Full CRUD is enabled with 'persist_immediately' turned on. Changes are applied as soon as the cell is blurred after making a change

edit-gridadd

Same as 'editable' except new rows are added directly to the grid instead of displaying an add record form

ed-inst-gridadd

Same as 'edit-instant' except new rows are added directly to the grid; "Save" must still be clicked before the row is actually inserted

read-only

No create/update/delete interfaces at all (rapidapp.pl default)

For more fine-grained control, RapidDbic configs can also be applied in model_config.

no_cleanup

Set to true to prevent the temp workdir from being cleaned up on exit (ignored when workdir is manually configured).

Defaults to false.

tmpdir

Parent temporary directory. Defaults to tmpdir from File::Spec (usually /tmp/)

workdir

Directory in which to generate temporary application files. If left unconfigured, this is an automatically generated directory 'rdbic-tmp-XXXXX' within tmpdir which is automatically cleaned/removed unless no_cleanup is true.

isolate_app_tmp

Set to true to override the location used for Catalyst temporary files to be contained within the workdir instead of within the system temp. This is useful to avoid leaving temporary files behind, but will slow startup because the asset files will be generated on each load.

Defaults to false, but set to true in the rdbic.pl script.

local_tmp

Directory to use for app_tmp when isolate_app_tmp is true. Defaults to tmp/ within the workdir

model_name

Name of the Model::DBIC in the generated app. Defaults to an auto-generated name based on the schema/dsn

model_config

Optional extra config to apply to the Model::DBIC in the generated app. This is useful to be able to customize RapidDbic configs (See Catalyst::Plugin::RapidApp::RapidDbic)

METHODS

to_app

PSGI $app CodeRef. Derives from Plack::Component

model_class

Full class name of the Model::DBIC in the generated app.

app_dir

Home directory for the generated RapidApp/Catalyst app. This will be the app name within the workdir

app_tmp

The temporary directory used by the generated RapidApp/Catalyst app. If isolate_app_tmp is true this will be within the workdir, or whatever directory is set in local_tmp. Otherwise it is the standard location returned by Catalyst::Utils::class2tempdir for the generated app (which is not cleaned up).

SEE ALSO

AUTHOR

Henry Van Styn <vanstyn@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by IntelliTree Solutions llc.

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