The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

SimpleDB::Class::Domain - A schematic representation of a SimpleDB domain.

VERSION

version 0.0100

DESCRIPTION

A subclass of this class is created for each domain in SimpleDB with it's name, attributes, and relationships.

METHODS

The following methods are available from this class.

new ( params )

Constructor. Normally you should never call this method yourself, instead use the domain() method in SimpleDB::Class.

params

A hash containing the parameters needed to construct this object.

simpledb

Required. A reference to a SimpleDB::Class object.

name

Required. The SimpleDB domain name associated with this class.

set_name ( name )

Class method. Used to set the SimpleDB domain name associated with a sublcass.

name

The domain name to set.

name ( )

Returns the name set in the constructor.

simpledb ( )

Returns the SimpleDB::Class object set in the constructor.

attributes ( )

Returns the hashref of attributes set by the add_attributes() method.

parents ( )

Returns the hashref of parents set by the belongs_to() method.

children ( )

Returns the hashref of children set by the has_many() method.

belongs_to ( method, class, attribute )

Class method. Adds a 1:N relationship between another class and this one.

method

The method name to create to represent this relationship in this class.

class

The class name of the parent class you're relating this class to.

attribute

The attribute in this class' attribute list that represents the id of the parent class.

has_many ( method, class, attribute )

Class method. Sets up a 1:N relationship between this class and a child class.

method

The name of the method in this class you wish to use to access the relationship with the child class.

class

The class name of the class you're creating the child relationship with.

attribute

The attribute in the child class that represents this class' id.

add_attributes ( list )

Class method. Adds more attributes to this class.

list

A hashref that holds a list of attributes and their properties (a hashref itself). Example: title => { isa => 'Str', default => 'Untitled' }

attribute

The attribute name is key in the hashref.

isa

The type of data represented by this attribute. Defaults to 'Str' if left out. Options are 'Str', 'Int', and 'DateTime'.

default

The default value for this attribute. This should be specified even if it is 'None' or 'Undefined' or 'Null', because actuall null queries are slow in SimpleDB.

create

Creates this domain in the SimpleDB.

delete

Deletes this domain from the SimpleDB.

find ( id )

Retrieves an item from the SimpleDB by ID and then returns a SimpleDB::Class::Item object.

id

The unique identifier (called ItemName in AWS documentation) of the item to retrieve.

insert ( attributes, [ id ] )

Adds a new item to this domain.

attributes

A hash reference of name value pairs to insert as attributes into this item.

id

Optionally specify a unqiue id for this item.

count ( [ where ] )

Returns an integer indicating how many items are in this domain.

where

A where clause as defined in SimpleDB::Class::SQL if you want to count only a certain number of items in the domain.

search ( where )

Returns a SimpleDB::Class::ResultSet object.

where

A where clause as defined by SimpleDB::Class::SQL.

AUTHOR

JT Smith <jt_at_plainblack_com>

I have to give credit where credit is due: SimpleDB::Class is heavily inspired by DBIx::Class by Matt Trout (and others), and the Amazon::SimpleDB class distributed by Amazon itself (not to be confused with Amazon::SimpleDB written by Timothy Appnel).

LEGAL

SimpleDB::Class is Copyright 2009 Plain Black Corporation and is licensed under the same terms as Perl itself.