DustyDB::Record - role for DustyDB models


version 0.06


  package MyModel;
  use DustyDB::Object;

  has key name => (
      is  => 'rw',
      isa => 'Str',
  has description => (
      is => 'rw',
      isa => 'Str',


Do not use this class directly. Use DustyDB::Object instead. The attributes and methods shown here are available in any class that uses DustyDB::Object because such classes do this role.



This is a required attribute that must be set to a DustyDB object that will be used to save this. In general, you will never need to set this yourself.

However, if you want to construct your record class directly, you can do something like this.

  my $db = DustyDB->new( path => 'foo.db' );
  my $object = MyModel->new( db => $db, name => 'foo', description => 'bar' );



  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.



This method delets the object from the database. This does not invalidate the object in memory or alter it in any other way.


When creating your models you cannot have an attribute named db or an attribute named class_name. The db name is used directly as an attribute by this role and class_name may be used when storing the data in some cases.