NAME
Presto - An Object Oriented Database System for Perl
SYNOPSIS
my $presto = Presto->new( $db_file );
$presto->register_class( 'Class1', 'Class2' );
my $obj = Class1->new( ... );
$obj->save;
$obj->delete;
my @objs = Class1->find( {
key1 => value1,
key2 => value2,
} );
$objs[0]->delete;
WARNING
This is completely and utterly alpha software. If you love your job, don't make it depend on this version of this module. This is being released solely for community comment.
If you like this module, please provide me with failing tests and API suggestions. I'll take patches, but I prefer faiilng tests demonstrating what you want Presto to do and how it's not doing it. You might find that, in the process of writing the failing test, Presto already does what you want. Plus, with the failing test, I see what you're trying to do. A patch doesn't tell me that.
DESCRIPTION
Presto is an object datastore, or OODBMS. There is nothing relational about it at all. You put objects in and you get objects out. Unlike "" in Pixie, there is no magic cookie. Unlike "" in DBM::Deep (which is the underlying engine), there is DBMS management provided for you, including indexing.
METHODS
- new
-
This is the constructor to create a new Presto object. It accepts one parameter, which is the filename of the Presto database.
- register_class
-
This accepts a single class name. It will add the following methods to it:
find()
This is a class method. It accepts a hashref of the key/value pairs you wish to find objects that match.
save()
This is an instance method. It will save that object and any children it has to the database. It will only call save() on children that are blessed into a registered class. When it is done, it will set the oid key to the object id.
If the object has no OID, it will perform an insertion. If it does, it will perform an update.
NOTE: The oid can be 0. Do NOT check the OID for truth. Instead, check to make sure that the oid key exists.
if ( exists $obj->{oid} ) { # Do something here }
delete()
This is an instance method. It will make sure that there is no object in the datastore with that object's OID. It will only delete that object, not any children.
TODO
Indices
Currently, there is NO indexing done. Every find() does the equivalent of a full-table scan. This will be added in version 0.02.
RESTRICTIONS
Hashes only
All objects must be blessed hashes. This restriction will go away in a later release. If you don't use blessed hashes and it blows up on you, don't complain. You've been warned.
SEE ALSO
"" in Presto::WTF, "" in DBM::Deep
CODE COVERAGE
We use "" in Devel::Cover to test the code coverage of our test suite. Here is the current coverage report:
---------------------------- ------ ------ ------ ------ ------ ------ ------
File stmt bran cond sub pod time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
blib/lib/Presto.pm 98.4 66.7 88.9 100.0 100.0 100.0 92.3
Total 98.4 66.7 88.9 100.0 100.0 100.0 92.3
---------------------------- ------ ------ ------ ------ ------ ------ ------
AUTHOR
Rob Kinyon <rob@iinteractive.com>
Stevan Little <stevan@iinteractive.com>
COPYRIGHT AND LICENSE
Copyright 2006 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.