DBIx::...ipDWIM(3pm)

πŸ“¦
version 2.037000 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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>


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