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

Ruby: How to get array instead of DataMapper::Collection in query result

here is my code: today_ids_from_db = Rating.all(:fields => 'my_id', :ts_d => Time.now) today_ids_from_db.class == DataMapper::Collection but I need to get simple ruby array with my_id values how to achieve this?
user973254
0
votes
2 answers

Using DataMapper ORM and Codeigniter to select join table value in a many to many relationship

I have this table structure: | users | --- has many > --- | preferences_users | --- < has many --- | preferences | A preference could be something like "first name" or "surname" but the value for these preferences are stored in the joining table. I…
Ian Jamieson
  • 4,376
  • 2
  • 35
  • 55
0
votes
1 answer

DataMapper: Set default validations on custom types

I just wrote a custom DM type to help me with this thing. Inherits from String, and all that jazz. Just now I'd like to have a default validation. So, something that I as a user don't need to define, it is just implicitly there. For instance, for an…
ChuckE
  • 5,610
  • 4
  • 31
  • 59
0
votes
1 answer

Case-insensitive index for a case-sensitive property

I have something like: class User include DataMapper::Resource property :id, Serial property :username, Text end I want usernames to be case-sensitive, so users can make usernames as they choose. What's the best way to then search for…
AlexQueue
  • 6,353
  • 5
  • 35
  • 44
0
votes
1 answer

DataMapper with multiple entities

Seeking some best practice advice. Basically I have a large entity that consists of various properties where some properties are other entities. What is the best practice of "instantiating" the big entity in my datamapper? Do I call the other…
neph
  • 733
  • 1
  • 8
  • 16
0
votes
1 answer

Data mapper doesnt return total_rows

$b->include_related('tent',NULL,TRUE,TRUE)->include_related('booking/guest',NULL,TRUE,FALSE)->include_related('booking/bookingbasis',NULL,TRUE,FALSE)->include_related('booking',NULL,TRUE,FALSE); $b->group_by('booking_id'); …
Gihan Dilusha
  • 891
  • 4
  • 14
  • 22
0
votes
1 answer

In Ruby, how to insert data on a DataMapper model created dynamically?

I'm trying to build a "fixture" feature for my Sinatra apps. I'm simply exporting databases to csv's with the name of the database, and using the filename as reference to access the class through datamapper. I know the database setup bellow is…
Manny
  • 43
  • 7
0
votes
1 answer

Datamapper, use yaml for configuration

I have a Sinatra app which uses DataMapper as it's ORM, it's deployed to Heroku, but I want to change the database details. Right now before my Models, I'm connecting to my DB like this, but I want to use a yml file to manage the connections…
JP Silvashy
  • 46,977
  • 48
  • 149
  • 227
0
votes
2 answers

Backbone data mapping

For mapping my backbone models to what I get from the server I am using a technique described on the GroupOn Dev blog:…
0
votes
1 answer

Update Table column

I use datamapper for the database. I have a table. class ZedTable include DataMapper::Resource property :id, Serial property :label, String property :now, Boolean, :default => false before :save do …
Mike
  • 1,042
  • 1
  • 8
  • 14
0
votes
2 answers

Lazy-add DataMapper results in a loop

When I want to do OR-queries with DataMapper I use result = MyModel.all(:first_name.like => '%john%') + MyModel.all(:last_name.like => '%john%') This works fine and generates only one SQL query. How can I create the same result with properties…
user1252065
0
votes
1 answer

DataObject::Integrity error in DataMapper

I wrote an app where I plan to save user data via DataMapper and sqlite3, and inventory items (several of them) using GDBM. When I run this with irb, User.new and inventory methods works fine however DataMapper says that my user model is not valid…
barerd
  • 835
  • 3
  • 11
  • 31
0
votes
1 answer

Mapping to Dictionary with iBATIS

Given a simple statement, such as: SELECT * FROM Products Is it possible to get a list of dictionary objects where the keys are the column names? ie. var list =…
Andrew
  • 1,494
  • 1
  • 17
  • 27
0
votes
2 answers

Can I have DataMapper and ActiveRecord use different database adapters in a Rails app?

I have a Rails application which has been using DataMapper. I am about to convert it to use ActiveRecord. If possible, I would like to do this one model (or group of models) at a time. Right now, I can't even get the app to boot because the two ORMs…
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
0
votes
1 answer

Ruby DataMapper - Serial column generating null error?

In the process of moving some pieces of my configuration into the database on a test app I built, I ran into a very odd issue. An error is generated whenever I attempt to create a new record in a table. The error is indicating that the SQL query…
Steve C.
  • 73
  • 6