NAME
DustyDB::Record - role for DustyDB models
VERSION
version 0.01
SYNOPSIS
package MyModel;
use Moose;
with 'DustyDB::Record';
has name => ( is => 'rw', isa => 'Str', traits => [ 'DustyDB::Key' ] );
has description => ( is => 'rw', isa => 'Str' );
DESCRIPTION
Use this role on any model object you want to store in the database.
ATTRIBUTES
model
This is a required attribute that must be set to a DustyDB::Model object that will be used to save this. In general, you will never need to set this yourself.
METHODS
save
my $key = $self->save;
This method saves the object into the database and returns a key identifying the object. The key is a hash reference created using the attributes that have the DustyDB::Key trait set.
delete
$self->delete;
This method delets the object from the database. This does not invalidate the object in memory or alter it in any other way.
CAVEATS
When creating your models you cannot have an attribute named model
or an attribute named class_name
. The model
name is already taken and class_name
may be used when storing the data in some cases.