EntityModel

Manage entity model definitions
Download

EntityModel Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Publisher Name:
  • Tom Molesworth
  • Publisher web site:
  • http://search.cpan.org/~team/

EntityModel Tags


EntityModel Description

Manage entity model definitions EntityModel is a Perl module that provides a data storage abstraction system (in the form of an Object Relational Model) for accessing backend storage from Perl and other languages. The intent is to take a model definition and generate or update database tables, caching layer and the corresponding code (Perl/C++/JS) for accessing data.SYNOPSIS use EntityModel; # Define model my $model = EntityModel->new->load_from( JSON => { entity : , primary => { field : , separator : ':' } ] } ); # Apply PostgreSQL schema (optional, only needed if the model changes) $model->apply('PostgreSQL' => { schema => 'datamodel', host => 'localhost', user => 'testuser' }); # Create Perl classes $model->apply('Perl' => { namespace => 'Entity', baseclass => 'EntityModel::EntityBase' }); my $article = Entity::Article->create( title => 'Test article', content => 'Article content' )->done(sub { my $article = shift; say "ID was " . $article->id; })->fail(sub { die 'Failed to create new article'; }); Entity::Article->find( title => 'Test article' )->first(sub { my $match = shift; $match->title('Revised title'); die "Instances of the same object should always be linked, consistent and up-to-date" unless $article->title eq $match->title; }); Requirements: · Perl


EntityModel Related Software