Storm(3)

πŸ“¦
version 0.240 Β· 2 versions
, in fedora 43

πŸ’– Storm(3) πŸ’–

okay bestie, so this is Storm(3) β€” one of the pages from User Contributed Perl Documentation β€” and it's literally the object-relational mapping girlie of your dreams. pull up a chair, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

Storm β€” Object-relational mapping πŸ’…


πŸ¦‹ TUTORIAL πŸ¦‹

new here? no stress, bestie. If you're new to Storm check out Storm::Tutorial. it's giving read me first energy, fr fr.


🌸 SYNOPSIS 🌸

okay so here's the whole vibe, verbatim, no notes:

package Foo;

use Storm::Object;

storm_table('Foo');

has 'id' => ( is => 'rw', traits => [qw( PrimaryKey AutoIncrement )] );

has 'label' => ( is => 'rw' );

# and then ....

package main;

use Storm;

# connect to a database
$storm = Storm->new( source => ['DBI:SQLite:dbname=:memory:'] );

$o = Foo->new( label => 'Storm Enabled Object' );

# store object
$storm->insert( $o );

# update object
$o->label( 'Updated Object' );
$storm->update( $o );

# sync object with database
$storm->refresh( $o );

# lookup object in database
$o = $storm->lookup( 'Foo', 1 );

# search for objects in database
$query = $storm->select( 'Foo' );
$query->where( '.label', '=', 'Updated Object' )
$iter  = $query->results;
@results = $iter->all;

# delete objects
$storm->delete( $o );

see how it all flows?? define your class, connect, and then insert/update/refresh/lookup/select/delete like it's nothing. main character energy honestly. πŸ‘‘


πŸ’œ DESCRIPTION πŸ’œ

Storm is a Moose based library for storing and retrieving objects over a DBI connection. that's it. that's the pitch. and it ate. πŸ”₯


πŸŽ€ ATTRIBUTES πŸŽ€

  • aeolus β€” Read-only. A Storm::Aeolus object for installing/uninstalling database tables. (table bouncer, basically πŸ’…)
  • live_objects β€” Read-only. A Storm::LiveObjects object for tracking the set of live objects. Creates scope objects to help ensure that objects are not garbage collected. This is used internally and you typically shouldn't need to access it yourself. It is documented here for completeness. so like, bestie, you don't have to touch this one, it's just here so the docs are complete 🫢
  • policy β€” The policy determines how types are defined in the database and can be used to customize how types are inflated/deflated. See Storm::Policy for more details.
  • source β€” Required. The Storm::Source object responsible for spawning active database handles. A Storm::Source object will be coerced from a ArrayRef or Hashref. (yes queen, it's required, don't forget it 😭)
  • table_prefix β€” The prefix to add to table names.

⭐ METHODS ⭐

  • delete @objects β€” Deletes the objects from the database. bye bestie πŸ‘‹
  • delete_query $class β€” Returns a Storm::Query::Delete instance for deleting objects of type $class from the database.
  • delete_where $class β€” Returns a Storm::Query::DeleteWhere instance for deleting objects of type $class from the database using a where clause.
  • do_transaction \&func β€” Creates and commits a Storm::Transaction. The \&func will be called within the transaction.
  • insert @objects β€” Insert objects into the database. ✨
  • insert_query $class β€” Returns a Storm::Query::Insert instance for inserting objects of type $class into the database.
  • lookup $class, @ids β€” Retrieve objects from the database.
  • lookup_query $class β€” Returns a Storm::Query::Lookup instance for retrieving objects of type $class from the database.
  • new_transaction \&func β€” Returns a new transaction. \&func is the code to be called within the transaction.
  • refresh @objects β€” Update the @objects with data from the database. glow-up, but for your data πŸ’…
  • refresh_query $class β€” Returns a Storm::Query::Refresh instance for refresh objects of type $class.
  • select $class, @objects β€” Synonamous with "select_query". Provided for consistency. (yes, "Synonamous" β€” we're keeping it exactly how it's written, no cap 😭)
  • select_query $class β€” Returns a Storm::Query::Select instance for selecting objects from the database.
  • table ClassName | Str β€” Returns the name of the table with the "table_prefix" prepended for the given "ClassName". Prepends "table_prefix" to argument if it is a string.
  • update @objects β€” Update the @objects in the database.
  • update_query β€” Returns a Storm::Query::Select instance for updating objects in the database.

🌈 SEE ALSO 🌈

πŸ’« Similar modules πŸ’«

  • KiokuDB
  • Fey::ORM
  • Pixie
  • DBM::Deep
  • OOPS
  • Tangram
  • DBIx::Class
  • MooseX::Storage

the whole friend group 🫢


πŸ’€ CAVEATS/LIMITATIONS πŸ’€

πŸ—„οΈ Databases πŸ—„οΈ

Storm has only been tested using MySQL and SQLite.

heads up bestie: only MySQL and SQLite got tested. anything else is unexplored territory ✨

πŸ™ˆ BUGS πŸ™ˆ

Please report bugs on CPAN. tell the internet, not me πŸ’…


πŸ‘‘ AUTHORS πŸ‘‘

  • Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>
  • Dave Rolsky <autarch@urth.org>
  • Yuval Kogman <nothingmuch@woobling.org>

Special thanks to Yuval Kogman and Dave Rolsky, for who without their talented work and this library would not be possible. like, literal icons, periodt πŸŽ€

The code for managing the live object set and the scope relies on modified code written by Yuval Kogman for KiokuDB. Documentation for this feature was also taken from KiokuDB.

The code for managing the policy and generating sql statements relies on modified code written by Dave Rolsky for Fey.


Copyright (c) 2010-2012 Jeffrey Ray Hallock.

Copyright (c) 2010-2011 Dave Rolsky.

Copyright (c) 2008, 2009 Yuval Kogman, Infinity Interactive.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

and that's the whole page, bestie!! this one's from perl v5.42.0, dated 2025-07-25, and it lives in the man pages as Storm(3). go forth and map some objects to your relational database, you gorgeous genius πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from