Storm::Model(3)
π Storm::Model(3) β aka Storm::Object
ok so bestie, you're looking at the Storm::Model(3) page from the User Contributed Perl Documentation section, and honestly? it's giving object-relational realness. buckle up π
β¨ NAME β¨
Storm::Object β build objects to use with Storm. that's it, that's the whole vibe π
π¦ SYNOPSIS π¦
no cap, this is the whole shape of it:
package Foo;
use Storm::Object; # provides Moose sugar
has 'id' => (
isa => 'Int',
traits => [qw( PrimaryKey AutoIncrement )],
);
has 'label' => (
isa => 'Str',
);
has 'bar' => (
isa => 'Bar',
weak_ref => 1,
)
package Bar;
has 'id' => (
isa => 'Int',
traits => [qw( PrimaryKey AutoIncrement )],
);
has_many 'foos' => (
foreign_class => 'Foo',
match_on => 'bar',
handles => {
foos => 'iter',
}
);
has_many 'bazzes' => (
foreign_class => 'Baz',
junction_table => 'BazBars',
local_match => 'bar',
foreign_match => 'baz',
handles => {
bazzes => 'iter',
add_baz => 'add',
remove_baz => 'remove',
}
);
package Baz;
has 'id' => (
isa => 'Int',
traits => [qw( PrimaryKey AutoIncrement )],
);
has_many 'bars' => (
foreign_class => 'Foo',
junction_table => 'BazBars',
local_match => 'bar',
foreign_match => 'baz',
handles => {
bars => 'iter',
add_bar => 'add',
remove_bar => 'remove',
}
);
like⦠it's a whole little polycule of classes and they all know each other 𫢠copy it exactly, the commas and semicolons are load-bearing, iykyk.
πΈ DESCRIPTION πΈ
okay so Storm::Object is an extension of the Moose object system. its whole purpose, its main character moment, is to apply the meta-roles Storm needs to be able to introspect your objects β and also to hand you some sugar for declaring relationships between Storm-enabled objects. sweet, right? π
π ROLES/META-ROLES π
these are the roles doing the behind-the-scenes work:
Storm::Role::Objectβ this role is applied to the base class. the foundation, the blueprint, the moment.Storm::Role::Object::Meta::Attributeβ this role is applied to the attribute meta-class. yes, the attribute one.Storm::Role::Object::Meta::Classβ and this role is applied to the class meta-class. periodt.
π§ SUGAR π§
has_many $name => %options
this is the big one, the icon, the queen bee π it takes a $name and a big old pile of %options:
foreign_class => $classβ set theforeign_classoption to the other class in the relationship. the plus-one, if you will πmatch_on => $attribute_nameβ use this one when you're defining a one-to-many relationship. it's the name of the attribute in the foreign class that defines the relationship.junction_table => $tableβ use this one when you're defining a many-to-many relationship. it's the database table that defines the relationships.local_match => $tableβ again for the many-to-many girlies. this is the column in thejunction_tablethat identifies the__PACKAGE__object in the relationship.foreign_match => $tableβ and last but not least, also for many-to-many. this is the column in thejunction_tablethat identifies the foreign object in the relationship. π
note bestie:local_matchandforeign_matchare both documented as taking$tablein the original, so that's what we're keeping. no editing the queen's typo history π
π AUTHOR π
Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com> β shoutout, the actual author, no notes π
π COPYRIGHT π
Copyright (c) 2010 Jeffrey Ray Hallock. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
so yeah, free software, same terms as Perl itself, slay π
okay bestie that's the whole page π this was Storm::Model(3) from perl v5.42.0, dated 2025-07-25 β go forth and build your objects, you've got this, no cap β¨π¦π
π¦ where this page comes from
- fedora 43: perl-Storm 0.240-34.fc43 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms