Different from most famous equivalent, Data::Model handles multi-database. In order to do that, every model was appointed its database and table name in addition to its schema specification.
Let's see a simple example:
This is a simplest model in Data::Model, Only two DDL in it.
base_driver( $driver )specify which database the model would connect to. $driver is a Data::Model::Driver::DBI object. Write those diffusion code in every model is really not perlish, so we extract all possible drivers to
The second, pass the table name and schema to
install_model(), this step is the same as above two ORM system. and then, all thing done. By the way,
columns()is the best syntax sugar provided by Data::Model::Schema.
Wait... Because Data::Model is too young to do auto_migration, we simply write
MyApp::DB::make_schema()to do that. Finally, we could do simple CRUD in our application. as below.
Though Data::Model is too young to have some important feature such as validator and hook, even has no ability to handle relation between two table. The prototype is really exciting.