.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "DBIx::Class::Helper::Row::JoinTable 3pm" .TH DBIx::Class::Helper::Row::JoinTable 3pm "2018-04-19" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBIx::Class::Helper::Row::JoinTable \- Easily set up join tables with DBIx::Class .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package MyApp::Schema::Result::Foo_Bar; \& \& _\|_PACKAGE_\|_\->load_components(qw{Helper::Row::JoinTable Core}); \& \& _\|_PACKAGE_\|_\->join_table({ \& left_class => \*(AqFoo\*(Aq, \& left_method => \*(Aqfoo\*(Aq, \& right_class => \*(AqBar\*(Aq, \& right_method => \*(Aqbar\*(Aq, \& }); \& \& # the above is the same as: \& \& _\|_PACKAGE_\|_\->table(\*(AqFoo_Bar\*(Aq); \& _\|_PACKAGE_\|_\->add_columns( \& foo_id => { \& data_type => \*(Aqinteger\*(Aq, \& is_nullable => 0, \& is_numeric => 1, \& }, \& bar_id => { \& data_type => \*(Aqinteger\*(Aq, \& is_nullable => 0, \& is_numeric => 1, \& }, \& ); \& \& $self\->set_primary_key(qw{foo_id bar_id}); \& \& _\|_PACKAGE_\|_\->belongs_to( foo => \*(AqMyApp::Schema::Result::Foo\*(Aq \*(Aqfoo_id\*(Aq); \& _\|_PACKAGE_\|_\->belongs_to( bar => \*(AqMyApp::Schema::Result::Bar\*(Aq \*(Aqbar_id\*(Aq); .Ve .PP or with DBIx::Class::Candy: .PP .Vb 1 \& package MyApp::Schema::Result::Foo_Bar; \& \& use DBIx::Class::Candy \-components => [\*(AqHelper::Row::JoinTable\*(Aq]; \& \& join_table { \& left_class => \*(AqFoo\*(Aq, \& left_method => \*(Aqfoo\*(Aq, \& right_class => \*(AqBar\*(Aq, \& right_method => \*(Aqbar\*(Aq, \& }; .Ve .SH "METHODS" .IX Header "METHODS" All the methods take a configuration hashref that looks like the following: .PP .Vb 10 \& { \& left_class => \*(AqFoo\*(Aq, \& left_method => \*(Aqfoo\*(Aq, # see NOTE \& left_method_plural => \*(Aqfoos\*(Aq, # see NOTE, not required, used for \& # many_to_many rel name in right_class \& # which is not generated by default \& right_class => \*(AqBar\*(Aq, \& right_method => \*(Aqbar\*(Aq, # see NOTE \& right_method_plural => \*(Aqbars\*(Aq, # see NOTE, not required, used for \& # many_to_many rel name in left_class \& # which is not generated by default \& namespace => \*(AqMyApp\*(Aq, # default is guessed via *::Foo \& self_method => \*(Aqfoobars\*(Aq, # not required, used for setting the name of the \& # join table\*(Aqs relationship in a has_many \& # which is not generated by default \& } .Ve .SS "join_table" .IX Subsection "join_table" This is the method that you probably want. It will set your table, add columns, set the primary key, and set up the relationships. .SS "add_join_columns" .IX Subsection "add_join_columns" Adds two non-nullable integer fields named \f(CW"${left_method}_id"\fR and \&\f(CW"${right_method}_id"\fR respectively. .SS "generate_has_manys" .IX Subsection "generate_has_manys" Installs methods into \f(CW\*(C`left_class\*(C'\fR and \f(CW\*(C`right_class\*(C'\fR to get to the join table. The methods will be named what's passed into the configuration hashref as \&\f(CW\*(C`self_method\*(C'\fR. .SS "generate_many_to_manys" .IX Subsection "generate_many_to_manys" Installs many_to_many methods into \f(CW\*(C`left_class\*(C'\fR and \f(CW\*(C`right_class\*(C'\fR. The methods will be named what's passed into the configuration hashref as \&\f(CW\*(C`left_method_plural\*(C'\fR for the \f(CW\*(C`right_class\*(C'\fR and \f(CW\*(C`right_method_plural\*(C'\fR for the \&\f(CW\*(C`left_class\*(C'\fR. .SS "generate_primary_key" .IX Subsection "generate_primary_key" Sets \f(CW"${left_method}_id"\fR and \f(CW"${right_method}_id"\fR to be the primary key. .SS "generate_relationships" .IX Subsection "generate_relationships" This adds relationships to \f(CW"${namespace}::Schema::Result::$left_class"\fR and \&\f(CW"${namespace}::Schema::Result::$left_class"\fR respectively. .SS "set_table" .IX Subsection "set_table" This method sets the table to \*(L"${left_class}_${right_class}\*(R". .SH "CANDY EXPORTS" .IX Header "CANDY EXPORTS" If used in conjunction with DBIx::Class::Candy this component will export: .IP "join_table" 4 .IX Item "join_table" .PD 0 .IP "generate_primary_key" 4 .IX Item "generate_primary_key" .IP "generate_has_manys" 4 .IX Item "generate_has_manys" .IP "generate_many_to_manys" 4 .IX Item "generate_many_to_manys" .IP "generate_relationships" 4 .IX Item "generate_relationships" .IP "set_table" 4 .IX Item "set_table" .IP "add_join_columns" 4 .IX Item "add_join_columns" .PD .SS "\s-1NOTE\s0" .IX Subsection "NOTE" This module uses (an internal fork of) String::CamelCase to default the method names and uses Lingua::EN::Inflect for pluralization. .SH "CHANGES BETWEEN RELEASES" .IX Header "CHANGES BETWEEN RELEASES" .SS "Changes since 0.*" .IX Subsection "Changes since 0.*" Originally this module would use .PP .Vb 3 \& data_type => \*(Aqinteger\*(Aq, \& is_nullable => 0, \& is_numeric => 1, .Ve .PP for all joining columns. It now infers \f(CW\*(C`data_type\*(C'\fR, \f(CW\*(C`is_nullable\*(C'\fR, \&\f(CW\*(C`is_numeric\*(C'\fR, and \f(CW\*(C`extra\*(C'\fR from the foreign tables. .SH "AUTHOR" .IX Header "AUTHOR" Arthur Axel \*(L"fREW\*(R" Schmidt .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2018 by Arthur Axel \*(L"fREW\*(R" Schmidt. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.