ObjectDB - Lightweight Object-relational mapper
ObjectDB is a lightweight, deps free (except DBI of course) and flexible object-relational mapper.
It combines all the best features from Class::DBI, DBIx::Class and Rose::DB but stays as light as possible.
ObjectDB abstract is not that heavy as in Rose::DB: columns are not objects, everything is pretty much straight forward and flat.
Embedded SQL generator is similar to SQL::Abstract, but leaves low-level sql generation still possible.
Returns true when object was created or loaded. Otherwise false.
Returns true when object was modified (setting columns). Otherwise false.
new
Returns a new ObjectDB object.
init
Sets objects columns.
schema
Used to define class schema. For more information see ObjectDB::Schema.
columns
Returns object columns that are set or have a default value.
column
Gets and sets column value.
clone
Object cloning. Everything is copied except primary key and unique key values.
begin_work
Begin transaction.
rollback
Roll back transaction.
commit
Commit transaction.
create
Creates a new object. Sets auto increment field to the last inserted id.
load
Loads object using primary key or unique key that was provided when creating a new instance. Dies if there was no primary or unique key.
update
Updates object.
delete
Deletes object.
find
Find objects. The second argument is a hashref that is translated into sql. Keys that can be used:
where
Build SQL. For more information see ObjectDB::SQL.
with
Prefetch related objects.
single
By default find returns array reference, by setting single to 1 undef or one object is returned (the first one).
order_by
ORDER BY
having
HAVING
limit
LIMIT
offset
OFFSET
page
With page_size you can select specific pages without calculation limit and offset by yourself.
page_size
The size of the page. It is 20 items by default.
Select only specific columns.
count
Count objects.
related
my $author = $article->related('author');
Gets prefetched related object(s).
create_related
Creates related objects.
find_related
Finds related objects.
load_related
Same as find_objects but sets related method.
find_objects
count_related
Counts related objects.
update_related
Updates related objects. Use set key for setting new values.
delete_related
Deletes related objects.
set_related
Creates and deletes related objects to satisfy the set. Usefull when setting many to many relationships.
to_hash
Serializes object to hash. All prefetched objects are serialized also.
http://github.com/vti/object-db/commits/master
Viacheslav Tykhanovskyi, vti@cpan.org.
vti@cpan.org
In alphabetical order:
Copyright (C) 2009, Viacheslav Tykhanovskyi.
This program is free software, you can redistribute it and/or modify it under the same terms as Perl 5.10.
To install ObjectDB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ObjectDB
CPAN shell
perl -MCPAN -e shell install ObjectDB
For more information on module installation, please visit the detailed CPAN module installation guide.