NAME
Storm - Object-relational mapping
TUTORIAL
If you're new to Storm check out Storm::Tutorial.
SYNOPSIS
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 );
DESCRIPTION
Storm is a Moose based library for storing and retrieving objects over a DBI connection.
ATTRIBUTES
- aeolus
-
Read-only.
A Storm::Aeolus object for installing/uninstalling database tables.
- 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.
- 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.
- table_prefix
-
The prefix to add to table names.
METHODS
- delete @objects
-
Deletes the objects from the database.
- 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.
- 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. - 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 givenClassName
. Prependstable_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
CAVEATS/LIMITATIONS
Databases
Storm has only been tested using MySQL and SQLite.
BUGS
Please report bugs on CPAN.
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.
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
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)