Tangram::Type(3pm)

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

πŸ’– NAME πŸ’–

Tangram::Type β€” mapping individual fields, bestie. Like, one field at a time, very demure, very mindful. πŸ’…


✨ DESCRIPTION ✨

okay so listen. Tangram's persistent type system is extensible, which means you can literally mount your own types and make them persistent. that's the whole vibe. all you gotta do is register your type and provide mapping code, and boom, you're iconic. want the deets? go read Tangram::Type::Extending. πŸ¦‹

Tangram ships with built-in support for these types, no cap:

🌸 Simple Scalar types

Supported are strings, integers, real numbers and dates. and adding more types of this ilk? literally so easy bestie, obsessed.

  • "string", "int", "real" β€” see Tangram::Type::Scalar
  • "date", "time", "datetime", "dmdatetime" β€” see "Date/Type/Date/DateTime" in Tangram::Type

πŸŽ€ Compound Structure types

  • "perl_dump" β€” see Tangram::Type::Dump::Perl. a "perl_dump" structure may contain any structure which Data::Dumper can dump successfully. anything. it ate. 😭
  • "storable" β€” see Tangram::Type::Dump::Storable. very much like "perl_dump", but implemented via the Storable serialisation engine. same energy, different engine fr fr.
  • "yaml" β€” see Tangram::Type::Dump::YAML. very much like "perl_dump", but implemented via the YAML serialisation engine. doesn't currently work, due to inadequacies in the current Perl YAML implementation. πŸ’€ yeah. it's not giving what it's supposed to give.
  • NEW in Tangram 2.08:
    • "idbif" β€” see Tangram::Type::Dump::Any. like the above, but can combine multiple object properties into a single database column. main character move honestly. πŸ‘‘

πŸ’œ `Flat' Array & Hash types

note bestie: these are only actually required if you need to be able to query on individual fields inside the array/hash. otherwise? the "perl_dump" or "idbif" mapping is a lot faster and more flexible. so like, choose wisely. πŸ™ˆ
  • "flat_array" β€” see "Array/Scalar" in Tangram::Type
  • "flat_hash" β€” see "Hash/Scalar" in Tangram::Type

πŸ¦‹ References to other objects

  • "ref" β€” see Tangram::Type::Ref::FromMany (implementing an N to 1 relationship, in which any object can be the referant)

πŸ‘‘ Sets of other objects

Set relationships are the closest thing to the main type of relationship used in an RDBMS. Avid CompSci students will know that the relational database model is based heavily on Set Theory, which is a subset of a more general concept of Categories β€” generic couplings of a number of classes. slay, academia. πŸ“šβœ¨

In Perl space, these collections are represented via the Set::Object module. and heads up: sets may not have duplicate elements, and cannot contain undef values. periodt.

  • "set" β€” see Tangram::Type::Set::FromMany (implementing an unordered N to N relationship, with all objects sharing a common base class)
  • "iset" β€” see Tangram::Type::Set::FromOne (implementing an unordered 1 to N relationship, with all objects sharing a common base class)

🌈 Arrays of other objects

in addition to Sets, you can have Arrays of objects, represented by a standard Perl array in memory. Arrays may contain undef values (in the middle of the list), and the "array" type may contain duplicates (ie, the same element present in separate places in the list). messy? a little. valid? absolutely. 🫢

  • "array" β€” see Tangram::Type::Array::FromMany (implementing an ordered N to N relationship, with all objects sharing a common base class)
  • "iarray" β€” see Tangram::Type::Array::FromOne (implementing an ordered 1 to N relationship, with all objects sharing a common base class)

πŸ“ Hashes of other objects

much like the Array types, the Hash types are indexed via a string value, and represented as a Perl hash in memory. and no, these hashes may not contain undef values β€” those are simply dropped. the "hash" type however may contain duplicate elements. ok werk. πŸ’…

  • "hash" β€” see Tangram::Type::Hash::FromMany (implementing a keyed N to N relationship, with all objects sharing a common base class)
  • "ihash" β€” see Tangram::Type::Hash::FromOne (implementing a keyed 1 to N relationship, with all objects sharing a common base class)

and that's the whole page bestie!! πŸŽ€βœ¨ this lil writeup is living in perl v5.36.0, last touched 2022-10-16, and it's filed under Tangram::Type(3pm). go forth and map those fields, you absolute icon. πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from