Tangra...FromOne(3pm)
π Tangra...FromOne β the Tangram::Type::Array::FromOne bestie guide (3pm) π
okay so. bestie. you wanna map Perl arrays with a foreign key? this is THE module for you. no cap. it lives in the Tangram::Type::Array::FromOne era of the Tangram universe and it's here to make your intrusive array mapping dreams come true. π¦
β¨ NAME β¨
Tangram::Type::Array::FromOne β map Perl arrays using a foreign key. that's literally the whole vibe. π
πΈ SYNOPSIS πΈ
use Tangram;
# or
use Tangram::Core;
use Tangram::Type::Array::FromOne;
$schema = Tangram::Schema->new(
classes => { Agenda => { fields => {
iarray =>
{
# long form
entries =>
{
class => 'Entry',
coll => 'agenda',
},
# or (short form)
entries => 'Entry',
}
look at that. two ways to say the same thing. long form girlies and short form girlies, we support both. π«Ά
π DESCRIPTION π
This class maps references to a Perl array in an intrusive fashion. (not intrusive like your ex, intrusive like database-intrusive, it's fine, it's fine.) The persistent fields get grouped up in a hash under the iarray key in the field hash.
The array may contain only objects of persistent classes. and those classes? they all gotta share a common persistent base class. no random strays allowed. π
Tangram uses two columns on the element's table to store:
- the id of the object containing the collection
- the position of the element in the collection
β οΈ CAUTION bestie: the same object may not be an element of the same collection, in two different objects. read that again. This mapping may be used only for one-to-many relationships. that's the rule, periodt. π¨
π§ the field descriptor tea
The field names are passed in a hash that associates a field name with a field descriptor. The field descriptor may be either a hash or a string. The hash uses the following fields:
classaggregbackcollslotdeep_update
π all about those fields
- Mandatory field
classβ specifies the class of the elements. you literally cannot skip this one, it's the main character. π - Optional field
aggregβ says that the elements of the collection must be removed (erased) from persistent storage along with the containing object. The default is not to aggregate. so by default they survive without their parent, dramatic but valid. π - Optional field
backβ sets the name of a field that gets inserted in the elements. That field acts as a demand-loaded, read-only reference to the object containing the collection. it's giving "look back at your parent" energy. β¨ - Optional field
collβ sets the name the column containing the id of the containing object. This defaults toC_m, whereCis the class of the containing object, andmis the field name. memorise the pattern, it'll come up again. π - Optional field
slotβ sets the name the column containing the id of the containing object. This defaults toC_m_slot, whereCis the class of the containing object, andmis the field name. same pattern, extra_slotsprinkle. π
π TheCinC_mandC_m_slotare passed through the schema normalisation function before being combined into a column name. so don't hardcode your assumptions, the schema is doing its own little transformation routine. π«
- Optional field
deep_updateβ specifies that all elements have to be updated automatically whenupdateis called on the collection object. Automatic update ensures consistency between the Perl representation and the DBMS state, but degrades update performance, so use it with caution. The default is not to do automatic updates. performance girlies, tread lightly. π
If the descriptor is a string, it is interpreted as the name of the element's class. This is equivalent to specifying only the class field in the hash variant. short form supremacy, honestly. π₯
π cute sign-off π
this lil page came from perl v5.36.0, dated 2022-10-16, and it's part of the User Contributed Perl Documentation for Tangra...FromOne(3pm). thanks for reading bestie, go build something iconic πβ¨π
π¦ 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