<div class="slide">
<h1>splitting logic cleanly</h1>
- <p>Foo::DBIC::Result::Foo = an individual row</p>
- <p>Foo::DBIC::ResultSet::Foo = searches / results</p>
+ <p>Foo::Schema::Result::Foo = an individual row</p>
+ <p>Foo::Schema::ResultSet::Foo = searches / results</p>
</div>
<div class="slide">
<div class="slide">
<h1>Schema::Loader</h1>
-<pre>Foo::DBIC::Result::Authors->table("authors");
-Foo::DBIC::Result::Authors->add_columns(
+<pre>Foo::Schema::Result::Authors->table("authors");
+Foo::Schema::Result::Authors->add_columns(
id => {
data_type => "INT",
default_value => undef,
size => 255,
},
);
-Foo::DBIC::Result::Authors->set_primary_key("id");</pre>
+Foo::Schema::Result::Authors->set_primary_key("id");</pre>
</div>
<div class="slide">
<h1>Schema::Loader</h1>
-<pre>Foo::DBIC::Result::Books->table("books");
-Foo::DBIC::Result::Books->add_columns(
+<pre>Foo::Schema::Result::Books->table("books");
+Foo::Schema::Result::Books->add_columns(
id => {
data_type => "INT",
default_value => undef,
size => 8
},
);
-Foo::DBIC::Result::Books->set_primary_key("id");</pre>
+Foo::Schema::Result::Books->set_primary_key("id");</pre>
</div>
<div class="slide">
<h1>Schema::Loader</h1>
-<pre>Foo::DBIC::Result::Authors->has_many(books => "Foo::DBIC::Books",
+<pre>Foo::Schema::Result::Authors->has_many(books => "Foo::Schema::Books",
{ "foreign.author" => "self.id" });
-Foo::DBIC::Result::Books->belongs_to(author => "Foo::DBIC::Authors",
+Foo::Schema::Result::Books->belongs_to(author => "Foo::Schema::Authors",
{ id => "author" });</pre>
</div>
<div class="slide">
<h1>overloading</h1>
-<pre>Foo::DBIC::Result::Books
-Foo::DBIC::ResultSet::Books
-Foo::DBIC::Result::Authors
-Foo::DBIC::ResultSet::Books</pre>
+<pre>Foo::Schema::Result::Books
+Foo::Schema::ResultSet::Books
+Foo::Schema::Result::Authors
+Foo::Schema::ResultSet::Books</pre>
</div>
<div class="slide">
<h1>Result::</h1>
-<pre>package Foo::DBIC::Result::Books;
+<pre>package Foo::Schema::Result::Books;
use base 'DBIx::Class';
use strict;
use warnings;
<div class="slide">
<h1>Result:: (inflating)</h1>
-<pre>package Foo::DBIC::Result::Books;
+<pre>package Foo::Schema::Result::Books;
use base 'DBIx::Class';
use strict;
use warnings;
<div class="slide">
<h1>Result:: (inflating)</h1>
-<pre>package Foo::DBIC::Result::Books;
+<pre>package Foo::Schema::Result::Books;
use base 'DBIx::Class';
use strict;
use warnings;
<div class="slide">
<h1>ResultSets::</h1>
-<pre>package Foo::DBIC::ResultSet::Books;
+<pre>package Foo::Schema::ResultSet::Books;
use base 'DBIx::Class::ResultSet';
sub the_ultimate_books {
my $self = shift;
<div class="slide">
<h1>ResultSets::</h1>
-<pre>package Foo::DBIC::<strong>ResultSet::Books</strong>;
+<pre>package Foo::Schema::<strong>ResultSet::Books</strong>;
use base '<strong>DBIx::Class::ResultSet</strong>';
sub the_ultimate_books {
my $self = shift;
<div class="slide">
<h1>ResultSets::</h1>
-<pre>package Foo::DBIC::ResultSet::Books;
+<pre>package Foo::Schema::ResultSet::Books;
use base 'DBIx::Class::ResultSet';
sub the_ultimate_books {
my $self = shift;
<div class="slide">
<h1>ResultSets::</h1>
-<pre>use Foo::DBIC;
-my $book_model = Foo::DBIC->resultset('Books');
+<pre>use Foo::Schema;
+my $book_model = Foo::Schema->resultset('Books');
my $book_rs = $book_model->the_ultimate_books;
my @books = $book_rs->all;</pre>
</div>
<div class="slide">
<h1>ResultSets::chaining</h1>
-<pre>use Foo::DBIC;
-my $book_model = Foo::DBIC->resultset('Books');
-my $author_model = Foo::DBIC->resultset('Authors');
+<pre>use Foo::Schema;
+my $book_model = Foo::Schema->resultset('Books');
+my $author_model = Foo::Schema->resultset('Authors');
my $author = $author_model->search({ name => 'Douglas Adams' })->single;
my $book_rs = $book_model->the_ultimate_books->by_author($author);
my @books = $book_rs->all;</pre>
<div class="slide">
<h1>overloading before new record</h1>
- <pre>package Foo::DBIC::Result::Authors;
+ <pre>package Foo::Schema::Result::Authors;
use base 'DBIx::Class';
sub new {
<div class="slide">
<h1>has_many</h1>
-<pre>package Foo::DBIC::<strong>Result::Books</strong>;
+<pre>package Foo::Schema::<strong>Result::Books</strong>;
-__PACKAGE__->has_many( author_and_books => "Foo::DBIC::Result::AuthorAndBooks",
+__PACKAGE__->has_many( author_and_books => "Foo::Schema::Result::AuthorAndBooks",
{ "foreign.book" => "self.id" },
);
<div class="slide">
<h1>has_many</h1>
-<pre>package Foo::DBIC::<strong>Result::Books</strong>;
+<pre>package Foo::Schema::<strong>Result::Books</strong>;
__PACKAGE__->has_many(
author_and_books => <strong># name of accessor</strong>
-"Foo::DBIC::Result::AuthorAndBooks", <strong># related class</strong>
+"Foo::Schema::Result::AuthorAndBooks", <strong># related class</strong>
{ "foreign.book" => "self.id" } <strong># Relationship (magic often works if not
# specified, but avoid!)</strong>
);
<div class="slide">
<h1>belongs_to</h1>
-<pre>package Foo::DBIC::<strong>Result::AuthorAndBooks</strong>;
+<pre>package Foo::Schema::<strong>Result::AuthorAndBooks</strong>;
__PACKAGE__->belongs_to(
book => <strong># Accessor name</strong>
- "Foo::DBIC::Result::Books", <strong># Related class</strong>
+ "Foo::Schema::Result::Books", <strong># Related class</strong>
{ id => "book" } <strong># relationship</strong>
);
</pre>
<div class="slide">
<h1>many_to_many</h1>
- <pre>package Foo::DBIC::<strong>Result::Books</strong>;
+ <pre>package Foo::Schema::<strong>Result::Books</strong>;
use base 'DBIx::Class';
__PACKAGE__->many_to_many(
<div class="slide">
<h1>many_to_many</h1>
- <pre>package Foo::DBIC::<strong>Result::Books</strong>;
+ <pre>package Foo::Schema::<strong>Result::Books</strong>;
use base 'DBIx::Class';
__PACKAGE__->many_to_many(
<div class="slide">
<h1>many_to_many</h1>
- <pre>package Foo::DBIC::Result::Authors;
+ <pre>package Foo::Schema::Result::Authors;
use base 'DBIx::Class';
__PACKAGE__->many_to_many(
<h1>using many_to_many</h1>
<pre>#!/usr/bin/perl
-use Foo::DBIC;
+use Foo::Schema;
-my $author_model = Foo::DBIC->resultset('Authors');
+my $author_model = Foo::Schema->resultset('Authors');
my $author = $author_model->search({
name => 'Douglas Adams',
})->single;
<div class="slide">
<h1>error messages</h1>
- <pre>DBIx::Class::Schema::Loader::connection(): Failed to load external class definition for 'Foo::DBIC::Result::Authors': Can't locate object method "many_to_many" via package "Foo::DBIC::Result::Author" at lib/Foo/DBIC/Result/Authors.pm line 9.Compilation failed in require at /Library/Perl/5.8.8/DBIx/Class/Schema/Loader/Base.pm line 292.</pre>
+ <pre>DBIx::Class::Schema::Loader::connection(): Failed to load external class definition for 'Foo::Schema::Result::Authors': Can't locate object method "many_to_many" via package "Foo::Schema::Result::Author" at lib/Foo/Schema/Result/Authors.pm line 9.Compilation failed in require at /Library/Perl/5.8.8/DBIx/Class/Schema/Loader/Base.pm line 292.</pre>
</div>
<div class="slide">
<h1>error messages</h1>
- <pre>DBIx::Class::Schema::Loader::connection(): Failed to load external class definition for 'Foo::DBIC::Result::Authors': Can't locate object method "many_to_many" via package "Foo::DBIC::<strong>Result::Author</strong>" at lib/Foo/DBIC/<strong>Result/Authors.pm</strong> line 9.Compilation failed in require at /Library/Perl/5.8.8/DBIx/Class/Schema/Loader/Base.pm line 292.</pre>
+ <pre>DBIx::Class::Schema::Loader::connection(): Failed to load external class definition for 'Foo::Schema::Result::Authors': Can't locate object method "many_to_many" via package "Foo::Schema::<strong>Result::Author</strong>" at lib/Foo/Schema/<strong>Result/Authors.pm</strong> line 9.Compilation failed in require at /Library/Perl/5.8.8/DBIx/Class/Schema/Loader/Base.pm line 292.</pre>
</div>
<div class="slide">
<div class="slide">
<h1>Catalyst</h1>
<pre>package Your::App::Model::<strong>Foo</strong>;
-use base qw(<strong>Catalyst::Model::DBIC::Schema</strong>);
+use base qw(<strong>Catalyst::Model::Schema::Schema</strong>);
use strict;
use warnings;
__PACKAGE__->config(
- schema_class => '<strong>Foo::DBIC</strong>',
+ schema_class => '<strong>Foo::Schema</strong>',
);
1;</pre>
<pre>sub action_name : Local {
my ($self, $c) = @_;
- my $model = $c->model('DBIC::Foo');
+ my $model = $c->model('Schema::Foo');
my $author_model = $model->resultset('Authors');
}