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

How do I put datamapper definition into a external file

I'm am working with datamapper in a classic Sinatra app and my file is getting to big to manage and troubleshoot. I was wondering if it would be possible to put my datamapper model definitions into one file the processing algorithms into another…
Triggs
  • 37
  • 1
  • 1
  • 7
0
votes
1 answer

Validating presence of 2 fields in DataMapper when an association does or does not exist

I have a model, User that has n, :accounts I want to validate the presence of 2 columns (email & passwd) in the User model when that instance does not have any associated accounts. The idea being that user that signs up with Facebook does not need…
nullfox
  • 597
  • 1
  • 4
  • 16
0
votes
1 answer

Why is datamapper trying to re-save my relationships?

I have a model called User who has a many to many relationship with Interests. Lets say the join table looks like this: User ID | Interest ID --------------------- 5 | 1 When I edit this user's name (for example) and call user.save, it…
Gerard
  • 4,818
  • 5
  • 51
  • 80
0
votes
2 answers

Freeze a property in DataMapper Model

Consider I have this following model definition, I want a particular property which should be constant from the moment it has been created class A property :a1, String, :freeze => true end Is there something like this? or may be using callbacks…
Mudassir Ali
  • 7,913
  • 4
  • 32
  • 60
0
votes
0 answers

Strange DataMapper Issue

I have a associative model, when I try to delete a record it returns true but the record still exists, The Model has 2 columns which are keys, while the third column is an enum, also a key.Any tips relating to updating/deleting a associative model…
Mudassir Ali
  • 7,913
  • 4
  • 32
  • 60
0
votes
1 answer

Difference between the mapper and the collection pattern in PHP

What is the difference between the mapper and the collection pattern in PHP?
user1683333
0
votes
1 answer

Setting NOW as a property on an object

I'm converting some old procedural code to OOP. Lets say I have some procedural code that marks a record as trashed and records the time that is done. UPDATE toys SET is_trashed = 1, trashed_date_timestamp = NOW() WHERE id = ?? I gather, from the…
JW.
  • 4,821
  • 5
  • 43
  • 60
0
votes
1 answer

Padrino: undefined method session for model

I am keep getting "NoMethodError at /dataset_requests/create undefined method `session' for #". DatasetRequest is a model, not controller. The problem is caused by flash and redirect methods. What might be the problem? My controller: Ims.controllers…
Jacek
  • 1,894
  • 5
  • 21
  • 34
0
votes
1 answer

Ruby - Datamapper - Collecting records by joining two models

I have two tables users ------- id name organization_id organizations ---------- id org_name org_unique_num abc xyz organization_id in users table is foreign key to organizations table's id class Organization include DataMapper::Resource …
JVK
  • 3,782
  • 8
  • 43
  • 67
0
votes
2 answers

Finding start and end date of month

I found code example for finding the start and end day of the current month I'm in. I tried to jump start this code, but am having a hard time figuring out what I have gone wrong. month = params[:month].to_i date_start = DateTime.new…
calabi
  • 283
  • 5
  • 18
0
votes
2 answers

Finding Records From This Month Datamapper with Sinatra

I'm building a little Sinatra web app at the moment and having problems understanding queries with DataMapper. I have a field in my database which I've called date, I'd love to query this and only return records from this current month. I've tried…
calabi
  • 283
  • 5
  • 18
0
votes
1 answer

Identity map pattern and table data gateway c#

I´m implementing Identity map pattern and DataMapper pattern in my project. But I have some problems. When I´m getting data from database by Gateway I´m creating new instance of object and return List ... What is the best way to implement getting…
Martin Haščák
  • 350
  • 6
  • 29
0
votes
1 answer

I am trying to run a rake task involving datamapper on heroku using scheduler but it seems that heroku is trying to use sqlite?!

I have a rakefile.rb in which there is task called add_latest_apps. This task creates some tables in a database if they have not been create using datamapper, scrapes some info from an xml feed and then puts the data in the tables. The problem is…
0
votes
1 answer

Query for the property from the associated table, computed values using DataMapper

Persons Table ------------------------------------------------------------ id | name | cost_price | sell_price | product_id | ------------------------------------------------------------ 1 person1 10000 20000 1 2…
Mudassir Ali
  • 7,913
  • 4
  • 32
  • 60
0
votes
1 answer

How to iterate over a collection of one to many relation in datamapper orm

I have two classes class Product extends DataMapper { var $has_one = array('category'); } class Category extends DataMapper { var $has_many = array('product'); } I need to get the all the products for the category and its sub-categories.…
Vijay Sharma
  • 373
  • 1
  • 10