Tuesday, July 7, 2009

the roadmap of upgrowth

和長輩們聊天總是很有趣的。即使那是一句老生常談,從長輩提攜的口吻中說出,依然受用。

6/26 的謝師宴,和賴暎杰老師坐在一起,我是這麼問的:「研究遇到瓶頸時,是怎麼面對的。」

「每天都多學會一件事,就不用擔心。」

yep...

 

Monday, July 6, 2009

Data::Model

Data::Model is a new ORM created by yappo, Its usage style is similar to DataMapper and Jifty::DBI.

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.

The first, 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 MyApp::DB::driver().



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.

[Chinese Version]

 

.