DBIx::...bleM2M(3pm)

πŸ“¦
version 0.001002 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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 (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