DBIx::...bleM2M(3pm)
β¨ NAME β¨
okay so you're reading the DBIx::...bleM2M(3pm) page (User Contributed Perl Documentation, hey π) and it's all about DBIx::Class::IntrospectableM2M β the module for introspecting many-to-many shortcuts. that's the whole assignment. no cap. π
πΈ SYNOPSIS πΈ
so bestie, in your DBIx::Class Result class β which people sometimes erroneously call the "table" class, and we don't do that here π β you drop this in:
__PACKAGE__->load_components(qw/IntrospectableM2M ... Core/);
#Digest encoder with hex format and SHA-1 algorithm
__PACKAGE__->many_to_many(roles => user_roles => 'role);
and then, when you actually want to introspect all that data:
my $metadata = $result_class->_m2m_metadata->{roles};
# $metadata->{accessor} method name e.g. 'roles'
# $metadata->{relation} maping relation e.g. 'user_roles'
# $metadata->{foreign_relation} far-side relation e.g. 'role
# $metadata->{attrs} relationship attributes, if any
# Convenience methods created by DBIx::Class
# $metadata->{rs_method} 'roles_rs'
# $metadata->{add_method} 'add_to_roles',
# $metadata->{set_method} 'set_roles',
# $metadata->{remove_method} 'remove_from_roles'
π Note: the component needs to be loaded before Core. that's not optional, that's the rules. π«Ά
π COMPATIBILITY NOTICE π
okay this part is the serious one, so listen up fr fr. this module is fairly esoteric, and unless you are out here dynamically creating something out of a DBIC Schema, it is probably the wrong solution for whatever it is you are trying to do. that's not me being mean, that's the docs being real with you. π
and the big one: compatibility is not guaranteed for DBIx::Class 0.09000+. they will try to maintain all compatibility, but internal changes might make that literally impossible. so likeβ¦ vibe check your dependencies before you commit, queen. π
π¦ DESCRIPTION π¦
here's the tea: many-to-many relationships are not real relationships, so DBIx::Class can't introspect them. they're not β¨realβ¨, they're just a collection of convenience methods installed to bridge two relationships. iconic behaviour honestly.
so this DBIx::Class component exists to store all the relevant information about these non-relationships, so that later you can introspect them and examine them. it's giving "receipts for the situationship" and I'm obsessed. π
π METHODS π
many_to_many
extended to store all the relevant information in the _m2m_metadata HASH ref. slay. π
_m2m_metadata
accessor to a HASH ref, where the keys are the names of m2m relationships and the value is a HASH ref, exactly as described in the SYNOPSIS above. go look, I'll wait. πΈ
π AUTHOR π
Guillermo Roditi (groditi) <groditi@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (C) 2008 by Guillermo Roditi
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the page bestie!! π¦ this one came to you from perl v5.34.0, dated 2022-06-13, and it's the DBIx::...bleM2M(3pm) manual page. go introspect something cute. mwah πβ¨
π¦ where this page comes from
- debian bookworm: libdbix-class-introspectablem2m-perl 0.001002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdbix-class-introspectablem2m-perl 0.001002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdbix-class-introspectablem2m-perl 0.001002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdbix-class-introspectablem2m-perl 0.001002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdbix-class-introspectablem2m-perl 0.001002-2 Β· 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