Tangra...omMany(3pm)

πŸ“¦
version 2.12 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸŽ€ 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:

  • class
  • aggreg
  • table
  • coll
  • item
  • deep_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 to C_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 to coll.
  • Optional field item β€” sets the name the column containing the ids of the elements. This defaults to item.
  • Optional field deep_update β€” specificies that all elements have to be updated automatically when update is 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