A Moose Role that adds a DBIx::Class persistence layer to your Moose class
with 'Model::Envoy' => { storage => { 'DBIC' => { schema => sub { ... connect to database here ... } } } };
The only configuration option for this plugin is a 'schema' method that returns a DBIx::Class:Schema based object with an open connection to the database.
DBIx::Class:Schema
dbic()
This is a method you will need to implement in each Model::Envoy object that use this storage plugin. It should return the name of the DBIx::Class ResultClass that your Model uses for database storage.
Model::Envoy
This role implements one trait:
Marking an attribute on your object with the 'DBIC' trait tells this role that it is backed by a DBIx::Class ResultClass column of the same name. It also allows for a few custom options you can apply to that attribute:
Indicates that this attribute corresponds to the primary key for the database record
Indicates that the attribute is a relationship to another model or a list of models. Possible values for this option are
For many-to-many relationships it is necessary to indicate what class provides the linkage between the two ends of the relationship ( the linking class maps to the join table in the database).
Takes a DBIx::Class result object and, if it's class matches your class's dbic() method, attempts to build a new instance of your class based on the $dbic_result passed in.
The `no_rel` boolean option prevents the creation process from traversing attributes marked as relationships, minimizing the amount of data pulled from the database and the number of new class instances created.
Returns the class instance if successful.
Performs either an insert or an update for the model, depending on whether there is already a record for it in the database.
Returns the calling object for convenient chaining.
Deletes the persistent copy of the current model from the database, if has been stored there.
Returns nothing.
Uses DBIx::Class's internal mechanisms to determine if this model is tied to a record in the database.
Returns a true value if it is, otherwise returns a false value.
To install Model::Envoy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Model::Envoy
CPAN shell
perl -MCPAN -e shell install Model::Envoy
For more information on module installation, please visit the detailed CPAN module installation guide.