Tangra...omMany(3pm)
π NAME π
Ok so the page we're on? It's the manual for Tangram::Type::Set::FromMany (section 3pm, the header up top literally gets chopped to Tangra...omMany(3pm) bestie, it's fine π
). What does it do? It maps a Set::Object using a link table. That's the whole vibe. No cap. π¦
β¨ SYNOPSIS β¨
use Tangram;
# or
use Tangram::Core;
use Tangram::Type::Set::FromMany;
$schema = Tangram::Schema->new(
classes => { Company => { fields => {
set =>
{
# long form
employee =>
{
class => 'Person',
table => 'Company_employees',
coll => 'company',
item => 'employee',
},
# short form
assets => 'Asset',
}
π DESCRIPTION π
So basically it maps a reference to a Set::Object. The persistent fields live all grouped together in a hash, sitting under the set key in the field hash. Slay. β¨
Here's the thing tho π the set can contain only objects of persistent classes, and those classes have to share a common persistent base class. Periodt.
Tangram uses a link table to save the state of the collection, and that table has two columns:
- one column holds the id of the container objects
- the other column holds the ids of the elements
The field names get passed in a hash that associates a field name with a field descriptor. And that field descriptor? It can be either a hash or a string, bestie, you get options πΈ. The hash uses these fields:
classaggregtablecollitemdeep_update
Let's break 'em down π«Ά:
- Mandatory field
classβ specifies the class of the elements. Required, no skipping, it's giving main character energy π - Optional field
aggregβ specifies that the elements of the collection must be removed (erased) from persistent storage along with the containing object. The default is not to aggregate. - Optional field
tableβ sets the name of the link table. This defaults toC_F, where C is the class of the containing object and F is the field name. - Optional field
collβ sets the name the column containing the ids of the containing objects. This defaults tocoll. - Optional field
itemβ sets the name the column containing the ids of the elements. This defaults toitem. - Optional field
deep_updateβ specificies that all elements have to be updated automatically whenupdateis called on the collection object. Automatic update ensures consisitency between the Perl representation and the DBMS state, but it degrades update performance so use it with caution β οΈ. The default is not to do automatic updates.
lowkey important: deep_update is the one that costs you, so don't just turn it on because it sounds cute. Use it with caution, fr fr.
If the descriptor is a string, it gets interpreted as the name of the element's class π«. This is equivalent to specifying only the class field in the hash variant.
And that's the whole thing, bestie! π This page came from the User Contributed Perl Documentation, it's perl v5.36.0, dated 2022-10-16, and it's still filed under Tangra...omMany(3pm) because even the header couldn't hold all those characters. Iconic behavior. Byeeee πβ¨
π¦ where this page comes from
- ubuntu noble: libtangram-perl 2.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtangram-perl 2.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtangram-perl 2.12-4 Β· 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