storage shortcut from paulm, version bump
[catagits/Catalyst-Model-DBIC-Schema.git] / README
1 NAME
2     Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class
3
4 SYNOPSIS
5         package MyApp::Model::Foo;
6         use strict;
7         use base 'Catalyst::Model::DBIC::Schema';
8
9         __PACKAGE__->config(
10             schema_class => 'Foo::SchemaClass',
11             connect_info => [ 'dbi:Pg:dbname=foodb',
12                               'postgres',
13                               '',
14                               { AutoCommit => 1 },
15                             ],
16         );
17
18         1;
19
20         # In controller code:
21
22         # ->schema To access schema methods:
23         $c->model('Foo')->schema->source(...);
24
25         # certain ->schema methods (source, resultset, class) have shortcuts
26         $c->model('Foo')->source(...);
27         $c->model('Foo')->resultset(...);
28         $c->model('Foo')->class(...);
29
30         # For resultsets, there's an even quicker shortcut:
31         $c->model('Foo::Bar')
32         # is the same as $c->model('Foo')->resultset('Bar')
33
34         # To get the composed schema for making new connections:
35         my $newconn = $c->model('Foo')->composed_schema->connect(...);
36
37         # Or the same thing via a convenience shortcut:
38         my $newconn = $c->model('Foo')->connect(...);
39
40         # or, if your schema works on different storage drivers:
41         my $newconn = $c->model('Foo')->composed_schema->clone();
42         $newconn->storage_type('::LDAP');
43         $newconn->connection(...);
44
45         # and again, a convenience shortcut
46         my $newconn = $c->model('Foo')->clone();
47         $newconn->storage_type('::LDAP');
48         $newconn->connection(...);
49
50 DESCRIPTION
51     NOTE: This is the first public release, there's probably a higher than
52     average chance of random bugs and shortcomings: you've been warned.
53
54     This is a Catalyst Model for DBIx::Class::Schema-based Models. See the
55     documentation for Catalyst::Helper::Model::DBIC::Schema and
56     Catalyst::Helper::Model::DBIC::SchemaLoader for information on
57     generating these Models via Helper scripts. The latter of the two will
58     also generated a DBIx::Class::Schema::Loader-based Schema class for you.
59
60 CONFIG PARAMETERS
61     schema_class
62         This is the classname of your DBIx::Class::Schema Schema. It needs
63         to be findable in @INC, but it does not need to be underneath
64         "Catalyst::Model::". This parameter is required.
65
66     connect_info
67         This is an arrayref of connection parameters, which are specific to
68         your "storage_type". For "::DBI", which is the only supported
69         "storage_type" in DBIx::Class at the time of this writing, the 4
70         parameters are your dsn, username, password, and connect options
71         hashref.
72
73         This is not required if "schema_class" already has connection
74         information defined in itself (which would be the case for a Schema
75         defined by DBIx::Class::Schema::Loader, for instance).
76
77     storage_type
78         Allows the use of a different "storage_type" than what is set in
79         your "schema_class" (which in turn defaults to "::DBI" if not set in
80         current DBIx::Class). Completely optional, and probably unnecessary
81         for most people until other storage backends become available for
82         DBIx::Class.
83
84 METHODS
85     new Instantiates the Model based on the above-documented ->config
86         parameters. The only required parameter is "schema_class".
87         "connect_info" is required in the case that "schema_class" does not
88         already have connection information defined for it.
89
90     schema
91         Accessor which returns the connected schema being used by the this
92         model. There are already direct shortcuts on the model class itself
93         for schema->resultset, schema->source, and schema->class.
94
95     composed_schema
96         Accessor which returns the composed schema, which has no connection
97         info, which was used in constructing the "schema" above. Useful for
98         creating new connections based on the same schema/model. There are
99         direct shortcuts from the model object for composed_schema->clone
100         and composed_schema->connect
101
102     clone
103         Shortcut for ->composed_schema->clone
104
105     connect
106         Shortcut for ->composed_schema->connect
107
108     source
109         Shortcut for ->schema->source
110
111     class
112         Shortcut for ->schema->class
113
114     resultset
115         Shortcut for ->schema->resultset
116
117     storage
118         Provides an accessor for the connected schema's storage object. Used
119         often for debugging and controlling transactions.
120
121 SEE ALSO
122     General Catalyst Stuff:
123
124     Catalyst::Manual, Catalyst::Test, Catalyst::Request, Catalyst::Response,
125     Catalyst::Helper, Catalyst,
126
127     Stuff related to DBIC and this Model style:
128
129     DBIx::Class, DBIx::Class::Schema, DBIx::Class::Schema::Loader,
130     Catalyst::Helper::Model::DBIC::Schema,
131     Catalyst::Helper::Model::DBIC::SchemaLoader
132
133 AUTHOR
134     Brandon L Black, "blblack@gmail.com"
135
136 COPYRIGHT
137     This program is free software, you can redistribute it and/or modify it
138     under the same terms as Perl itself.
139