NAME
Mandel::Model - An object modelling a document
DESCRIPTION
This class is used to descrieb the structure of document in mongodb.
ATTRIBUTES
collection_name
The name of the collection in the database. Default is the plural form of "name".
collection_class
The class name of the collection class. This default to Mandel::Collection.
document_class
The class name of the document this description is attached to. Default to an autogenerated class name.
name
The name of this model. Same as given to "model" in Mandel and "collection" in Mandel.
METHODS
field
$field_obj = $self->field('name');
$self = $self->field(name => \%meta);
$self = $self->field(['name1', 'name2'], \%meta);
Used to define new field(s) or retrieve a defined Mandel::Model::Field object.
fields
@fields = $self->fields;
Get list of Mandel::Model::Field objects in the order they were added to thie model.
relationship
$rel_obj = $self->relationship($type => $accessor => 'Other::Document::Class', %args);
$rel_obj = $self->relationship($accessor);
This method is used to describe a relationship between two documents.
See Mandel::Relationship::BelongsTo, Mandel::Relationship::HasMany or Mandel::Relationship::HasOne.
$accessor
will be used as l<Mandel::Relationship/accessor>, "Other::Document::Class" will be used as "related_class" in Mandel::Relationship and Mandel::Model/document_class
will be used as "document_class" in Mandel::Relationship.
%args
is passed on the the relationship constructor.
new_collection
$self->new_collection($connection);
Returns a new instance of "collection_class".
SEE ALSO
AUTHOR
Jan Henning Thorsen - jhthorsen@cpan.org