Questions tagged [datamapper]

Architectural pattern for separating application logic from storage.

Objects and relational databases have different mechanisms for structuring data.

The Data Mapper is a layer of software that separates the in-memory objects from the database. Its responsibility is to transfer data between the two and also to isolate them from each other. With Data Mapper the in-memory objects needn't know even that there's a database present; they need no SQL interface code, and certainly no knowledge of the database schema.

Pattern definition: http://martinfowler.com/eaaCatalog/dataMapper.html

1134 questions
0
votes
1 answer

datamapper - query over an object property

using datamapper with ruby. Suppose i have a model called Post: class Post include DataMapper::Resource property :id, Serial property :name, String, length: 255 property :category_ids, Object end Post.create(name: 'My post', category_ids:…
Marcus Mansur
  • 337
  • 1
  • 4
  • 14
0
votes
2 answers

DataMapper: Fetching only changed properties before updating record

Hoping someone can point me in the right direction with this. I want to know if there's a way to view/fetch both new and old property values with DataMapper before the update method is called and compare the values. The scenario is as follows: I…
ghstcode
  • 2,902
  • 1
  • 20
  • 30
0
votes
2 answers

Ruby Data_Mapper resource not able to be saved - expecting different data type

I'm attempting to save some information relating to real estate in my local area. I'm using Ruby with the Data_Mapper gem to persist the data to a local MySQL database. The models currently look like thus: class Property include…
Michael
  • 33
  • 5
0
votes
1 answer

How to access environment in datamapper migration

I have a padrino server application with datamapper as ORM layer. I have a database migration, say: migrate 1, :test do up do execute 'Some Query' end end This migration is run using the command: padrino rake dm:migrate -e Now my…
constantine1
  • 427
  • 1
  • 5
  • 12
0
votes
1 answer

Impedance Mismatch: Repository pattern + Mapper + Cursor + SQLite

I'm building an ORM based on the repository pattern. Inside the repository I create something that I call a "data source" to fetch results from the db and map them to entity objects. Each data source is created with a query, and is responsible for…
benjist
  • 2,740
  • 3
  • 31
  • 58
0
votes
2 answers

Using Doctrine 2 / DataMapper, how do I persist new entities in the domain layer?

I have a tree-like structure with a couple of entities: a process is composed of steps and a step may have sub-processes. Let's say I have 2 failure modes: abort and re-do. I have tree traversal logic implemented that cascades the fail signal up…
Nate
  • 209
  • 3
  • 7
0
votes
1 answer

Autocomplete with Vim and Rails Datamapper

Is there a way that I can have auto completion in Vim after I load a model from the database? So for example if I have a model of type Foo with an instance method of type bar and do the following foo = Foo.first(:param=>'x') foo.b should show me…
Ramiro
  • 470
  • 1
  • 4
  • 6
0
votes
0 answers

Datamapper - Reading from an existing reference table (Oracle)

I'm a bit new to Sinatra / Datamapper and I am currently attempting to create a model based on an existing table. We have an employee forum which stores the users' employee ID when they create a post. Obviously when we display the information, we…
ash
  • 1,224
  • 3
  • 26
  • 46
0
votes
1 answer

Datamapper dirty properties

I'm sure I remember a way to get a list of the properties for a resource that are dirty, but I can't seem to find the method anywhere. So is there some method for returning an array of dirty properties?
Anthony DeSimone
  • 1,994
  • 1
  • 12
  • 21
0
votes
0 answers

DataMapper and Single Table Inheritance

I have parent Person with two children Employee and Member, and Member has two children Regular and Premium. I have implemented the Single Table Inheritance approach in the database. now i would like to ask about the datamapper, how should it look…
Sisyphus
  • 900
  • 12
  • 32
0
votes
1 answer

3-tier architecture and data mapper

i have an domain object at the BAL that should have a corresponding data mapper at the DAL. as known the data mapper class will hold presistance and retrieval methods like Update, Delete, FindById, FindByName etc. i understand how those DAL methods…
Sisyphus
  • 900
  • 12
  • 32
0
votes
1 answer

Active Record: Why it adds things like "save"?

Why a Product object, for example, has a method called Save? It seems to me that it is wrong for a Product saving yourself in the database. A product should not only know only about their own responsibility? Did I not understand the purpose of AR or…
Maykonn
  • 2,738
  • 6
  • 33
  • 51
0
votes
1 answer

Benefits of adding associations in ActiveRecord Models?

I am creating active record associations for the first time and would like to understand what to expect after I have added them. I am using rails 3.2.14 I have 3 tables Users, Applications and Jobs 1] In application table I have added User_Id and…
codeObserver
  • 6,521
  • 16
  • 76
  • 121
0
votes
1 answer

How to convert OpenSSL Digest result to BigDecimal/DataMapper::Property::Decimal

i have something like this: x = OpenSSL::Digest::SHA512.new('test').digest #…
Kokizzu
  • 24,974
  • 37
  • 137
  • 233
0
votes
1 answer

Mapper: Object to Key-Values

I have a domain object (DO) and Key-Value (KV) objects. How would I map each field of DO to instance of KV? Example: class DomainObject { String field1 = "value1"; String field2 = "value2"; } class KeyValue { String key; String…
surlac
  • 2,961
  • 2
  • 22
  • 31