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
2 answers

datamapper secondary key

I am using datamapper in a ruby application and I'm facing a problem I do not understand. I have a Appartment model and a Location model. An appartment is at a given location and several appartments can be at the same location. This typically…
Luc
  • 16,604
  • 34
  • 121
  • 183
0
votes
2 answers

Reusing a resultMap for different column names

Is there a way of reusing the same resultMap multiple times in a single query. For example, suppose I have a "foo" resultMap: Is there a way to define another…
Andrew
  • 1,494
  • 1
  • 17
  • 27
0
votes
1 answer

Datamapper with existing database- tables with primary key column name other than id

I am running a application using codeigniter framework. I have a database. I want to implement datamapper ORM. Since for datamapper- "Every table must have a primary key named id". I have an auto increment integer field in all tables. But the column…
piyush
  • 976
  • 4
  • 13
  • 28
0
votes
0 answers

Datamapper set_join_field without update

I'm trying to save some date with a join_field basically I have an add-up function and an count-down function if(isset($_POST['min_product'])) { foreach($_POST['min_product'] as $index => $min_product_id) { …
WouterV
  • 133
  • 1
  • 11
0
votes
1 answer

How to get aggregate totalling with data from two Models in DataMapper?

I am new to DataMapper and Ruby, and have been struggling to work out a way to format the expression which will give me what I am after. Let me explain. I have two Models in my project: Class Manufacturer include DataMapper::Resource property…
CyberFerret
  • 275
  • 3
  • 8
0
votes
1 answer

Need to define an alias for a DataMapper property

I am working on a Padrino/Sinatra app that is using the jQuery UI Autocomplete in a certain section. To populate the autocomplete, I have defined the following: get '/autocompletedata' do content_type :json Foo.all.to_json(:only =>…
CyberFerret
  • 275
  • 3
  • 8
0
votes
1 answer

Query generated by Rails datamapper has "id" column name missing

So I have a class as shown below class A include DataMapper::Resource property :id, Serial # other properties When I run the following command rake db:create db:migrate db:automigrate I get the following error rake aborted! ERROR: syntax…
JunaidKirkire
  • 878
  • 1
  • 7
  • 17
0
votes
2 answers

How to initialize Ruby Datamapper object from JSON?

I'm using Ruby with Sinatra and DataMapper. It is simple enough to create a "get" webservice that delivers a data set to a UI with something like Item.all().to_json However, the intent is for the UI to use the data set for crud work and return a…
user2836927
  • 37
  • 1
  • 5
0
votes
2 answers

Simplifying an inequality for an SQL query

For reference, this question was boggled, so thanks to everyone who helped unboggle it. I'm trying to locate potential collisions of events in a booking program where events have varying lengths. (a ≤ x && e ≥ y) || (a ≥ x && e ≤ y) || (a ≤ x && e ≤…
arbales
  • 5,466
  • 4
  • 33
  • 40
0
votes
0 answers

How does DataMapper gem separate the application logic and data persistence?

This is a get started example of Ruby data mapper. However, how does this example illustrate the power of datamapper that separate the application logic and data persistence? Any better example can give us that the separation can lead us do unit…
TheOneTeam
  • 25,806
  • 45
  • 116
  • 158
0
votes
1 answer

ibatis datamapper scripts a stored-procedure with some default parameters

How can I make a robust datamapper script in xml if the target stored-procedure have some parameters added but indeed with default values ?? For instance, I designed a stored-procedure with some default parameters like this, CREATE PROCEDURE…
nwpie
  • 665
  • 11
  • 24
0
votes
1 answer

In the data mapper pattern, is it worth tracking which fields have changed?

Given the following: $userMapper = new UserMapper($db); $user = $userMapper->find(381); $user->name = 'Derp' //was Durr $userMapper->save($user); Is it worth building logic into the UserMapper to detect that only name has changed, so as to build a…
AgmLauncher
  • 7,070
  • 8
  • 41
  • 67
0
votes
0 answers

Serializing simple object graph using different serialization methods per object

I am currently working on a multi-page form, where I am populating a domain object book during the forms. In between the forms I store and load the book by serializing and unserializing it from session using the native php functions serialize,…
0
votes
1 answer

Datamapper [ruby] on Legacy Schemas

I'm working with a legacy schema which has 3 particular tables backing a single class, listed below: table_1_month # All items that are < 1 month old. table_1_year # All items that are between 1 month and 1 year old. table # All items that are…
0
votes
1 answer

How to overwrite Ruby DataMapper's create and first_or_create method?

I could overwrite DataMapper's save, delete, destroy! method using module, such as: require 'data_mapper' module Record def self.included(base) base.class_eval do include DataMapper::Resource property :id,…
Kokizzu
  • 24,974
  • 37
  • 137
  • 233