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

1130 questions
8
votes
3 answers

datamapper multi-field unique index

In Datamapper, how would one specify the the combination of two fields must be unique. For example categories must have unique names within a domain: class Category include DataMapper.resource property :name, String, :index=>true #must be unique…
John F. Miller
  • 25,556
  • 8
  • 66
  • 120
8
votes
3 answers

PHP DataMapper with multiple persistence layers

I am writing a system in PHP that has to write to three persistence layers: One web service Two databases (one mysql one mssql) The reason for this is legacy systems and cannot be changed. I am wanting to use the DataMapper pattern and I am trying…
John Royal
  • 361
  • 4
  • 13
7
votes
2 answers

Complex DataMapper query association

im a beginner with DataMapper ORM, so i have question about complex querying. First, here is simplified data objects: class User property :id, Serial property :login, String has n, :actions end class Item property :id, Serial …
Dan Sosedoff
  • 2,683
  • 5
  • 25
  • 34
7
votes
1 answer

Deploy a simple test app with Sinatra + DataMapper + Postgres + Heroku returns: Installing do_sqlite3 (0.10.7) error

Goal: Deploy a simple test app with Sinatra + DataMapper + Postgres + Heroku Issue: When using gem 'dm-postgres-adapter' gem 'dm-sqlite-adapter' to push the app to Heroku I get this. Installing do_sqlite3 (0.10.7) with native extensions…
tripdragon
  • 183
  • 2
  • 12
7
votes
2 answers

Case insensitive like (ilike) in Datamapper with Postgresql

We are using Datamapper in a Sinatra application and would like to use case insensitive like that works on both Sqlite (locally in development) and Postgresql (on Heroku in production). We have statements like TreeItem.all(:name.like…
moonhouse
  • 555
  • 3
  • 19
7
votes
2 answers

Displaying Error Message with Sinatra

I'm writing a simple app that takes standard input from the user. As for the email entry, I have it verify if it is in a standard email format and then have it list the problems like this when a new instance is going to be saved: u =…
captDaylight
  • 2,092
  • 3
  • 29
  • 39
7
votes
2 answers

Data Mapper + Observer pattern

I'm building an app in PHP and I'm using the data mapper pattern for my DB access. I was considering using the Observer pattern to have all my mappers observe the entities they create, so that they can automatically save any changes back to the…
Jack Sleight
  • 16,671
  • 6
  • 38
  • 53
7
votes
3 answers

Data Mapper API - unsure about organisation

Let's say we have "User" and a "Hotel" model classes. I'd use a User_Mapper and Hotel_Mapper to load/save/delete etc. I want to then have the user be able to mark their "favourite" hotels. In the database I have my user_favourite_hotels table which…
James
  • 71
  • 1
7
votes
1 answer

Is parsing a json naively into a Python class or struct secure?

Some background first: I have a few rather simple data structures which are persisted as json files on disk. These json files are shared between applications of different languages and different environments (like web frontend and data manipulation…
benjist
  • 2,268
  • 2
  • 21
  • 48
7
votes
2 answers

Separating business logic from PHP Doctrine 2

I use symfony 2.3 and php doctrine 2. The program has the following models: entity Order - a typical customer order entity BadOrderEntry(fields: id, order - unidirectional one-to-one relationship with Order, createdAt) factory BadOrderEntryFactory…
stalxed
  • 1,023
  • 2
  • 9
  • 12
7
votes
4 answers

What's the significant difference between active record and data mapper based ORMs?

Like doctrine(active record) and Xyster(data mapper),what's the difference?
user198729
  • 55,886
  • 102
  • 239
  • 342
7
votes
3 answers

Master / Slave switch in the Zend Framework application layer

I am writing an application which requires the Master/Slave switch to happen inside the application layer. As it is right now, I instantiate a Zend_Db_Table object on creation of the mapper, and then setDefaultAdapter to the slave. Now inside of…
Pro777
  • 1,604
  • 1
  • 16
  • 30
7
votes
1 answer

Strategic Eager Loading for many-to-many relations in Datamapper?

I'm using DataMapper, an open source ORM for ruby, and I have in itch I would like to scratch. At the moment, DataMapper can use Strategic Eager Loading(SEL) for one-to-many relationships, but not many-to-many, where N+1 queries occur. I would…
John F. Miller
  • 25,556
  • 8
  • 66
  • 120
7
votes
3 answers

Datamapper: Sorting results through association

I'm working on a Rails 3.2 app that uses Datamapper as its ORM. I'm looking for a way to sort a result set by an attribute of the associated model. Specifically I have the following models: class Vehicle include DataMapper::Resource belongs_to…
Peter Duijnstee
  • 3,679
  • 2
  • 17
  • 30
6
votes
3 answers

.NET Native GUID conversion

I have an external database that is feeding information to me. One saves their data as native GUID format and my other data source supplies standard .NET GUID format string. Is there a tidy way to convert from Native GUID to GUID Structure? Also is…
Seph
  • 7,864
  • 10
  • 58
  • 86
1 2
3
75 76