Cataly...:Schema(3pm)
β¨ NAME β¨
Catalyst::Helper::Model::DBIC::Schema β bestie, it's the Helper for DBIC Schema Models π
So like, this is a Perl manpage (a 3pm one, from the User Contributed Perl Documentation crew), and it's here to help you generate DBIx::Class Schema Models without losing your whole entire mind. Slay. π
π¦ SYNOPSIS π¦
script/create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass \
[ create=dynamic | create=static ] [ traits=trait1,trait2... ] \
[ Schema::Loader opts ] [ dsn user pass ] \
[ other connect_info args ]
πΈ DESCRIPTION πΈ
It's a Helper for the DBIC Schema Models. That's the whole vibe. Let's get into the details because the details are, lowkey, the entire point. π
Arguments:
"CatalystModelName"β this is the short name for the Catalyst Model class you're generating, i.e. the one you can call with$c->model('CatalystModelName'). Cute, right?"MyApp::SchemaClass"β the fully qualified classname of your Schema, and it might or might not already exist, no pressure. But heads up: you should have a good reason to create this under a brand new global namespace β otherwise, bestie, just use an existing top level namespace for your schema class. Fr fr."create=dynamic"β this tells the Helper to generate the named Schema class for you, basing it on DBIx::Class::Schema::Loader. Which means (and this is the key part) the table information will always be dynamically loaded at runtime from the database. Always. Every time. π"create=static"β this tells the Helper to generate the named Schema class for you, using DBIx::Class::Schema::Loader in "one shot" mode, to create a standard, manually-defined DBIx::Class::Schema setup based on whatever the Loader sees in your database at this exact moment. A Schema/Model pair generated this way will not require DBIx::Class::Schema::Loader at runtime, and will not automatically adapt itself to changes in your database structure. (Not me writing a schema and then changing my database and being shocked π.) You can edit the generated classes by hand to refine them, though. Iconic."traits"β the list of traits to apply to the model. See Catalyst::Model::DBIC::Schema for the details."Schema::Loader opts"β these are documented in DBIx::Class::Schema::Loader::Base, and some examples are given in "TYPICAL EXAMPLES" below. π"connect_info"β these arguments are the same as what"connect"in DBIx::Class::Schema expects, and they are storage_type-specific. They're documented in"connect_info"in DBIx::Class::Storage::DBI. For DBI-based storage, these arguments are the dsn, username, password, and connect options, respectively. These are optional for existing Schemas, but required if you use either of the"create="options. No cap.- username and password can be omitted for
"SQLite"dsns. π
β οΈ Use of either of the "create=" options requires DBIx::Class::Schema::Loader. Like, it's not optional. It's giving dependency.
π₯ TYPICAL EXAMPLES π₯
Use DBIx::Class::Schema::Loader to create a static DBIx::Class::Schema, and a Model which references it:
script/myapp_create.pl model CatalystModelName DBIC::Schema \
MyApp::SchemaClass create=static dbi:mysql:foodb myuname mypass
Same, with extra connect_info args β user and pass can be omitted for sqlite, since they are always empty:
script/myapp_create.pl model CatalystModelName DBIC::Schema \
MyApp::SchemaClass create=static dbi:SQLite:foo.db \
AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \
on_connect_do='["select 1", "select 2"]' quote_names=1
πͺ ON WINDOWS COMMAND LINES QUOTING RULES ARE DIFFERENT
In "cmd.exe" the above example would be:
script/myapp_create.pl model CatalystModelName DBIC::Schema \
MyApp::SchemaClass create=static dbi:SQLite:foo.db \
AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \
on_connect_do="[\"select 1\", \"select 2\"]" quote_names=1
Same, but with extra Schema::Loader args (separate multiple values by commas):
script/myapp_create.pl model CatalystModelName DBIC::Schema \
MyApp::SchemaClass create=static db_schema=foodb components=Foo,Bar \
exclude='^(wibble|wobble)$' moniker_map='{ foo => "FOO" }' \
dbi:Pg:dbname=foodb myuname mypass
Coderefs are also supported, bestie. The way that works is so cool:
script/myapp_create.pl model CatalystModelName DBIC::Schema \
MyApp::SchemaClass create=static \
inflect_singular='sub { $_[0] =~ /\A(.+?)(_id)?\z/; $1 }' \
moniker_map='sub { join(q{}, map ucfirst, split(/[\W_]+/, lc $_[0])); }' \
dbi:mysql:foodb myuname mypass
See DBIx::Class::Schema::Loader::Base for a list of options π
Create a dynamic DBIx::Class::Schema::Loader-based Schema, and a Model which references it (DEPRECATED):
π DEPRECATED. You've been warned. She's retired but still showing up to the party.
script/myapp_create.pl model CatalystModelName DBIC::Schema \
MyApp::SchemaClass create=dynamic dbi:mysql:foodb myuname mypass
Reference an existing Schema of any kind, and provide some connection information for ->config:
script/myapp_create.pl model CatalystModelName DBIC::Schema \
MyApp::SchemaClass dbi:mysql:foodb myuname mypass
Same, but don't supply connect information yet (you'll need to do this in your app config, or [not recommended] in the schema itself).
script/myapp_create.pl model ModelName DBIC::Schema My::SchemaClass
π§ METHODS π§
mk_compclass
This is called by Catalyst::Helper with the commandline args to generate the files. She's the one doing the actual work. πͺ
run
Can be called on an instance to generate the files. Yes, on an instance. Very object-oriented of her. β¨
π SEE ALSO π
General Catalyst Stuff:
- Catalyst::Manual, Catalyst::Test, Catalyst::Request, Catalyst::Response, Catalyst::Helper, Catalyst,
Stuff related to DBIC and this Model style:
- DBIx::Class, DBIx::Class::Schema, DBIx::Class::Schema::Loader, Catalyst::Model::DBIC::Schema
π AUTHOR π
See "AUTHOR" in Catalyst::Model::DBIC::Schema and "CONTRIBUTORS" in Catalyst::Model::DBIC::Schema. The legends are credited over there. π«Ά
π COPYRIGHT π
See "COPYRIGHT" in Catalyst::Model::DBIC::Schema.
β LICENSE β
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. Free as in, go off, do your thing. π
And that's the whole page, bestie! This one came to you via perl v5.36.0, dated 2023-10-26, from the good people of User Contributed Perl Documentation. Go build something cute. πβ¨
π¦ where this page comes from
- debian trixie: libcatalyst-model-dbic-schema-perl 0.66-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcatalyst-model-dbic-schema-perl 0.66-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatalyst-model-dbic-schema-perl 0.66-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatalyst-model-dbic-schema-perl 0.66-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms