App-AutoCRUD

 view release on metacpan or  search on metacpan

lib/App/AutoCRUD/DataSource.pm  view on Meta::CPAN

if the schema itself was bound to another dbh by a remote module -- the
dbh will be forced again before processing the HTTP request).


=head2 schema

An instance or a subclass of L<DBIx::DataModel::Schema>.
Usually this is loaded from parameters specified in the configuration tree;
if such parameters are absent, the fallback behavior is to generate
a class on the fly, using L<DBIx::DataModel::Schema::Generator>.


=head2 query_parser

An instance of L<SQL::Abstract::FromQuery>, for parsing the content
of search forms.

=head2 tablegroups

Information about tables in that datasource. This is an ordered list
of I<tablegroups>, where each tablegroup is a hashref with a B<name>,
a B<descr> (description), and an ordered list of I<tables>.
Each table in that list contains information as returned by
the L<DBI/table_info> method, plus an additional B<descr> field.

The tablegroups structure comes from the configuration data. If tables
are found in the database, but not mentioned in the configuration, they are
automatically inserted into a group called "Unclassified".


=head1 METHODS

=head2 config

  my $data = $datasource->config(@path);

Returns the config subtree at location C<@path> under this datasource.

=head2 descr

Returns the description string for this datasource, as specified in config.

=head2 prepare_for_request

  $datasource->prepare_for_request($req);

Called from L<App::AutoCRUD/call> before serving
a request. This is a hook for subclasses to provide application-specific
behaviour if needed (like for example resetting the database connection
or supplying user credentials from the HTTP request).
The argument C<$req> is an instance of L<Plack::Request>.

=head2 primary_key

Proxy method to L<DBIx::DataModel::Meta::Source/primary_key>.

=head2 colgroups

  my $colgroups = $datasource->colgroups($table_name);

Returns an arrayref of I<column groups>, as specified in config (or guessed
from the database meta-information, if the config says nothing).

Each column group is a hashref with keys C<name> (containing a string)
and C<columns> (containing an arrayref of I<columns>).

Each column is a hashref as returned from L<DBI/column_info>, i.e. containing
keys C<TABLE_NAME>, C<COLUMN_NAME>, C<DATA_TYPE>, C<COLUMN_SIZE>, etc.
In addition, some other keys are inserted into this hashref : 

=over

=item is_pkey

Boolean indicating that this column is part of the primary key

=item paths

An arrayref of I<paths> to other tables. Each path is a hashref with
keys C<name> (name of this path), C<to_table> (name of the associated table),
C<foreign_key> (name of the associated column in the remote table).

=back





( run in 2.690 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )