DustyDB::Key - mark an attribute as being part of the primary key


DustyDB documentation  | view source Contained in the DustyDB distribution.

Index


NAME

Top

DustyDB::Key - mark an attribute as being part of the primary key

VERSION

Top

version 0.06

SYNOPSIS

Top

  package MyModel;
  use DustyDB::Object;

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

DESCRIPTION

Top

This is a basic marker role that just notifies DustyDB that the attribute should be used to define the primary key (one of the attributes that uniquely identifies it) for the object.

ATTRIBUTES

Top

stringify

This may be defined as a reference to a subroutine to be used to translate a non-scalar attribute into a scalar key value. For example, if you want to use a date via DateTime as a key, you could do:

  has key timestamp => (
     is => 'rw',
     isa => 'DateTime',
     stringify => sub { $_->iso8601 },
  );

METHODS

Top

perform_stringify

This is a helper for executing the code reference in the stringify attribute correctly.


DustyDB documentation  | view source Contained in the DustyDB distribution.