Given a schema like so:use Moose; with 'orm'; has table => ( name => 'my_database_table' );
+--------------------+------------------+ | Field | Type | +--------------------+------------------+ | id | int(10) unsigned | | field1 | varchar(32) | | field2 | varchar(32) | +--------------------+------------------+My ORM.pm role would parse this line:
And effectively produce a Moose object that would be essentially the same as explicitly coding:has table => ( name => 'my_database_table' );
The idea, however, is not to produce a text file ... but rather an in-memory object. I could always use Perl to create the text file for me, i.e. this one liner:use Moose; has id => ( is => 'ro', isa => 'Int' ); has field1 => ( is => 'rw', isa => 'Str' ); has field2 => ( is => 'rw', isa => 'Str' );
I have searched for others who might have this same desire, but so far no real luck. I imagine will need to use Moose::Exporter or possibly Moose::Util::MetaRole. I really don't know.mysql -e 'desc my_database_table' | cut -f1 | perl -ple '$_=qq{has $_ +=> ( is => "rw" );}'
So, my question isn't "can someone do this for me?" but rather ... are there any Moose heads out there who might be able to sketch out a rough game plan for solving this problem. Personally, I am starting to believe this is more trouble than it is worth. But please remember -- I am not looking for a fully functional ORM that handles complex relationships -- just some sugar for preventing having to spell out the names of the columns in the table for now. I myself am not sure this is a great idea. :)
Thanks in advance.
In reply to Moose + ORM by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |