Let's use it
- Yeah, that's a lot of code for a slide
- Imagine the existence of a "foo" table and a "foo_tags" table
package MyApp::Schema::MapFooTags;
use strict; use warnings;
use base 'DBIx::Class';
use MapMaker;
my $mapmaker = MapMaker->new(
left_class => 'MyApp::Schema::Foo',
right_class => 'MyApp::Schema::FooTag',
left_name => 'foo',
right_name => 'tag',
tablename => 'map_foo_tags',
);
- When you use DBICx::Deploy, you get the map_foo_tags table
- And you can:
my $foo = $schema->resultset('Foo')->find(42);
my @tags = $foo->tags;
my $tag = $schema->resultset('FooTag')->find(1);
my @foos = $tag->foos;