I have two repositories set up within data mapper as follows:
DataMapper.setup(:default, "sqlite://path/to/db1")
DataMapper.setup(:another, "sqlite://path/to/otherdb")
Lets say I have a model Foo
that they both share a schema for. This is the pseudocode that I want to accomplish:
DataMapper.repository(:default){
Foo.each do |f|
# do some transformations
# write to Foo table in DataMapper.repository(:another)
end
}
How would I go about this?
The way I ended up doing it:
DataMapper.repository(:default){
Foo.each do |foo|
DataMapper.repository(:another){
newFoo = Foo.new
newFoo.attributes = foo.attributes
newFoo.save
}
end
}