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
4
votes
1 answer

Datamapper's hooks won't work

Can't understand why hooks don't work. I have the following model: class DirItem include DataMapper::Resource # property , property :id, Serial property :dir_cat_id, Integer, :required => true property :title, String,…
4
votes
2 answers

Should ORM calls be inside the Model or Controller?

Question What are the Best Practices on where place the ORM's implementation in a MVC like software application? I'm using Laravel, with Eloquent, the default ORM. The documentation alludes to the fact that ORM calls are fine in the Controller, but…
Mike
  • 8,767
  • 8
  • 49
  • 103
4
votes
1 answer

Beginning with Datamapper, Association question

I'm just diving into Datamapper (and Sinatra) and have a question about associations. Below are some models I have. This is what I want to implemented. I'm having an issue with Workoutitems and Workout. Workout will be managed separately, but…
user258082
4
votes
2 answers

Trim String In Automapper

Mapper.CreateMap() My Source Here Contains String Values Coming from user interface. I want to trim all the string before i map it to my destination object. Couldn't find a solution for this. Anyone Knows how this is to…
Koushik Saha
  • 673
  • 1
  • 10
  • 25
4
votes
1 answer

Datamapper Clone Record w/ New ID

class Item include DataMapper::Resource property :id, Serial property :title, String end item = Item.new(:title => 'Title 1') # :id => 1 item.save item_clone = Item.first(:id => 1).clone item_clone.save # =>
BouncePast
  • 41
  • 3
4
votes
1 answer

Taking the data mapper approach in Zend Framework

Let's assume the following tables setup for a Zend Framework app. user (id) groups (id) groups_users (id, user_id, group_id, join_date) I took the Data Mapper approach to models which basically gives me: Model_User, Model_UsersMapper,…
4
votes
1 answer

Should a Finder Method be part of the Data Mapper, or part of the domain class?

In Martin Fowler's Patterns for Enterprise Application Architectures book (page 229 in German, Lazy Load) he gives an example with this code: public List getProducts() { if (products == null) products = Product.findForSupplier(getID()); …
openfrog
  • 40,201
  • 65
  • 225
  • 373
4
votes
1 answer

Ruby & Datamapper checking if a record exists, and where?

I have a basic Ruby app that I am building with Sinatra, Datamapper and has user authentication using OAuth. When I receive the data back from the Oauth service, I save a record of a new user in an sqlite3 db. What I don't know how to do is how to…
kylemac
  • 623
  • 2
  • 7
  • 15
4
votes
5 answers

What is the best MVC, Doctrine2, Datamapper practice?

I am looking into using Doctrine2 with my Zend Framework setup. I really like the datamapper pattern, mainly because it seperates my domain models with my database. My question is what is the best practice for using Doctrine and DQL with my…
SuneKibs
  • 145
  • 1
  • 9
4
votes
1 answer

How to use DataMapper `NOT LIKE` clause?

I'm using DataMapper in a Sinatra project. I'd like to be able to use a NOT LIKE stament in a DataMapper finder method, but cannot figure out how to do so. One might imagine that this would work: @people = People.all(:female => 1, :name.like.not…
Jack7890
  • 1,311
  • 4
  • 19
  • 27
4
votes
2 answers

Some uncertainty with implementing the 3 structure Model (Domain object, data mapper and service)

As the heading suggests I am having some small problems while implementing the 3 structure Model (Domain object, data mapper and service). In the past when someone was registering on my site I would simply do $user->register($firstName, $lastName,…
ibanore
  • 1,500
  • 1
  • 12
  • 25
4
votes
1 answer

How to implement Data Mapper / Repository persistence patterns for diverse data sources?

I am writing a new website project pretty much from scratch. The project is in C# but my background is in PHP (the pseudo-code below is a bit if a mixture, trying to be both succinct and declarative). The problem I need to retrieve configuration…
4
votes
1 answer

Datamapper TEXT limited to 65k characters by default — how to raise the limit?

I have a class that needs to have TEXT up to about 300k characters and it's stored in a PostgreSQL db. Postgres itself has no problem with megabyte blobs, (eventually I will store them in S3), but Datamapper has a default limit of '65k characters'…
Tom Andersen
  • 7,132
  • 3
  • 38
  • 55
4
votes
1 answer

How to save an object when you do not know if its parent objects exist or not?

I have three tables, Business: id name Office: id name business_id Employee: id name office_id Employee's have office_id as a foreign key and Offices have business_id as a foreign key. I have a domain object/entity that relates to…
Mark
  • 5,423
  • 11
  • 47
  • 62
4
votes
2 answers

Multiple worker threads working on the same database - how to make it work properly?

I have a database that has a list of rows that need to be operated on. It looks something like this: id remaining delivered locked ============================================ 1 10 24 f 2 6 …
MikeC8
  • 3,783
  • 4
  • 27
  • 33