Tangram::Type::Dump::Any - Intuitive DataBase InterFace


Tangram documentation  | view source Contained in the Tangram distribution.

Index


NAME

Top

Tangram::Type::Dump::Any - Intuitive DataBase InterFace

SYNOPSIS

Top

  # ... in a nearby Tangram::Schema structure ...
  SomeClass =>
    { fields =>
      { idbif => {
            -options => { dumper => 'Data::Dumper',
                        },
            some_field => undef,
            some_property => undef,
            some_attribute => undef,
            each_one => undef,
            gets => undef,
            saved => undef,
        },
        string => {
            cheese => undef,
        },
      },
    };

DESCRIPTION

Top

The idbif mapping type collates multiple data members into a single perl_dump (see Tangram::Type::Dump::Perl), storable (see Tangram::Type::Dump::Storable) or yaml (see Tangram::Type::Dump::YAML) column.

For instance, with the schema definition in the example, all the columns in the example would be serialised via Data::Dumper.

If you stored an object like this:

  $cheese = bless { cheese   => "gouda",
                    gets     => 6,
                    each_one => 9 }, "SomeClass";

You would see something in your database similar to:

  /^'--v------v--------v----------------------------'^\
  | id | type | cheese | idbif                        |
  >----o------o--------o------------------------------<
  |  1 |   42 |  gouda | { gets => 6, each_one => 9 } |
  \_,--^------^--------^----------------------------._/

(note: the actual output from your SQL Database client may differ from the above)

So, if you're the sort of person who likes to set their attributes with accessors, but doesn't like the overhead this places on the RDBMS... then this may help. Note: the real benefits of this mapping type are for when you're storing more complex data structures than "6" and "9" :-).

You may prefer to use the default dumping type, which is storable.

BUT, I REALLY, REALLY HATE SCHEMAS!

However, maybe you are one of those folk who don't like to declare their attributes, instead peppering hashes willy nilly, then there is another option.

Instead of explicitly listing the fields you want, if you don't specify any fields at all, then it means save ALL remaining fields into the column. For convenience, -poof is provided as a synonym for -options, so you can write:

    { fields =>
      { idbif => { -poof => # There goes another one!
                   {
                   },
                 }
      },
    }

[ You see, Tangram::Type::Dump::Any isn't actually an intuitive DB interface. No, an intuitive DB interface is a user interface component, and that title is reserved for Visual Tangram. VT expects to pick up the title with any luck by the end of the 21st century^W RSN!

I Don't Believe In Fairies is actually what it stands for. It's a completely arbitrary name; chosen for no reason at all, and certainly not anything to do with Pixie. ]


Tangram documentation  | view source Contained in the Tangram distribution.