DBIx::...ipDWIM(3pm)
π DBIx::Class::Helper::Row::RelationshipDWIM π
okay so bestie, this is from the User Contributed Perl Documentation collection, and it's filed under the manual name DBIx::...ipDWIM(3pm) (yes the filename got a lil squished, she's fine, she's just like that π
).
β¨ NAME β¨
DBIx::Class::Helper::Row::RelationshipDWIM β type less for your relationships!! Like, genuinely, that's the whole pitch. The DWIM stands for "do what I mean" and she MEANS it. π«Ά
β¨ SYNOPSIS β¨
Okay so first, the base class. This is the vibe:
package MyApp::Schema::Result;
use parent 'DBIx::Class::Core';
__PACKAGE__->load_components('Helper::Row::RelationshipDWIM');
sub default_result_namespace { 'MyApp::Schema::Result' }
1;
Then in your result class:
package MyApp::Schema::Result::Foo;
use parent 'MyApp::Schema::Result';
# Define various class bits here
# succinct relationship definition yeah!
__PACKAGE__->has_many(friends => '::Person', 'foo_id');
# or with DBIx::Class::Candy:
has_many friends => '::Person', 'foo_id';
1;
See that ::Person?? No giant package path, no scrolling, no carpal tunnel. Iconic. π
β¨ DESCRIPTION β¨
So here's the tea β β this module looks at your related objects, and if one of them starts with ::, it just goes ahead and sticks your default_result_namespace on the front of it. That's it. That's the whole module.
Simple but handy, fr fr. Like a tiny lil fairy godmother for your relationship names π§β¨
β¨ AUTHOR β¨
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
β¨ COPYRIGHT AND LICENSE β¨
This software is copyright (c) 2024 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. So go off, bestie, remix it, share it, it's yours π
And that's a wrap!! perl v5.40.0, dated 2024-11-16 β that's the version and the date, mwah, no cap. Go define some relationships and go to bed. πΈπ¦
π¦ where this page comes from
- debian trixie: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdbix-class-helpers-perl 2.037000-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