dynamic tables

17 views
Skip to first unread message

Clark Snowdall

unread,
May 10, 2012, 8:59:15 PM5/10/12
to DataMapper
Hello all,

I've dabbled in datamapper in the past, but don't have much experience
in it. I'm trying to evaluate its usefulness for solving a problem I
have.

I have a number of tables (probably ~50) that I need to get data
from. Each table has 5 columns in common. Beyond those 5 columns
each table has various numbers of various other columns; none of them
in common with other tables.

I would like to find a means of ORM that would allow me to declare a
single model that could handle the basic 5 pieces of common data, but
then also access the extra columns dynamically depending on what table
was specified. I would really prefer NOT to have to write 50 or so
models (especially since this number is being added to and subtracted
from in an ongoing fashion). I was wondering if perhaps Datamapper
might be able to solve this in a clean dynamic way.

Thoughts anyone?

Thanks,
Snowdall

Dan Kubb (dkubb)

unread,
May 11, 2012, 12:02:44 AM5/11/12
to datam...@googlegroups.com
Hi


I would like to find a means of ORM that would allow me to declare a
single model that could handle the basic 5 pieces of common data, but
then also access the extra columns dynamically depending on what table
was specified.  I would really prefer NOT to have to write 50 or so
models (especially since this number is being added to and subtracted
from in an ongoing fashion).  I was wondering if perhaps Datamapper
might be able to solve this in a clean dynamic way.

You could look at using dm-reflection to get a list of models based on the current structure of your database. You could mix in a single module into each model if you wanted to share some common behaviour between them. It should be possible to handle this completely dynamically without hard coding any model names or table/column names into the system anywhere.

-- 

Dan
Reply all
Reply to author
Forward
0 new messages