Freitag, Oktober 31, 2008

legacy databases with datamapper

For my current project I choose datamapper wich has some advantages over ActiveRecord. I need a thread safe ORM which doesnt need to do much but performing real fast. I am dealing with legacy table names but couldnt find any documentation how this is done though its very simple:

Your model needs a method storage_name like :

def self.storage_name(repository)
  "your_legacy_table_name"
end

Repository can be ignored if you are just dealing with one database.

ps: afcool83 mentioned a smarter way to do this:

storage_names[:default]='your_legacy_table_name'

Kommentare:

afcool83 hat gesagt…

You can do

class User
include DataMapper::Resource
storage_names[:default]='your_legacy_table_name'
# properties here....
end

Martin Wöginger hat gesagt…

thats way cooler, thanks!