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

DataMapper all_to_json() method returning slashes

I just found DataMapper for CI's built in to_json and all_to_json methods, which saved me a ton of time. How can I return relations with the result? Currently my code looks like this: $homes = new…
Seth
  • 6,240
  • 3
  • 28
  • 44
0
votes
2 answers

merb cannot load dm-mysql-adapter

Would you help me on this issue? gem list shows that dm-mysql-adapter has been installed, but merb cannot load it. I just want to start a simple merb application generated by merb-gen. Loading init file from ./config/init.rb Loading…
Hardbone
  • 327
  • 1
  • 3
  • 16
0
votes
2 answers

Testing Datamapper models with RSpec

I'm testing a Sinatra application, which is using DataMapper, with RSpec. The following code: it "should update the item's title" do lambda do post "/hello/edit", :params => { :title => 'goodbye', :body => 'goodbye world' } …
Samy Dindane
  • 17,900
  • 3
  • 40
  • 50
0
votes
1 answer

DataMapper Self Relation Model

Hi I am using CodeIgniter with DataMapper and really need some help defining relationship in a model class (DataMapper Model Class) How would I write the model relation for this. Slightly confused about the Self relation, i.e menu item and sub…
ebsol
  • 3
  • 4
0
votes
1 answer

How do you use a row from one table as a property in another table using Datamapper?

The specific instance I am referring to is here. I want to use a row from the Grid table to be the value of the Grid property in the Driver table. But I cannot get updates in the Grid table to persist through to the Grid property on the Driver…
JoeyC
  • 764
  • 11
  • 19
0
votes
1 answer

How can I get DataMapper to return a sepcific number of elements?

say I have class MyClass include DataMapper::Resource property :id, Serial property :my_property, Text end How can I make a call to return a maximum of 3 items Such as MyClass.all(:my_property => "some_text", :max => 3) Where the :max =>…
Lev Dubinets
  • 788
  • 10
  • 32
0
votes
1 answer

errors with the name of the table in Datamapper ( city )

I've a model called City in datamapper for codeigniter. I've kept the name of the table as "cities" because datamapper expects the name of the table in pluralized form. Now when I create the object for the model in controller ( $c = new City(); ); I…
Shashi Roy
  • 323
  • 3
  • 7
  • 22
0
votes
1 answer

Returning associated objects from Rails controller with Datamapper

I have two models which are related to one another (many to many) and I want to return them both in the response from my Rails controller action. The two classes are User and Location. There is also a link class UserLocation. User.rb looks…
Gerard
  • 4,818
  • 5
  • 51
  • 80
0
votes
2 answers

DataMapper: dm-timestamps doesn't play nice with dm-validations?

It seems that validations in DataMapper run before dm-timestamps has a chance to autoset the created_at and updated_at fields. Consider the following: require 'dm-core' require 'dm-migrations' require 'dm-timestamps' require 'dm-validations' class…
Jeremy Burton
  • 873
  • 6
  • 10
0
votes
1 answer

Transactions in Datamapper & Rails (dm-rails)

I have two models: hotel and location. A location belongs to a hotel, a hotel has one location. I'm trying to create both in a single form, bear in mind that I can't use dm-nested for nested forms due to a dependency clash. I have code that looks…
Gerard
  • 4,818
  • 5
  • 51
  • 80
0
votes
1 answer

multiple database connection in CI

can i connection with multiple database main connections is from database.php but the another one in from the model and i want to switch between it like this $config['remote']['hostname'] = 'localhost'; $config['remote']['username']…
dev.bashar
  • 191
  • 1
  • 2
  • 14
0
votes
1 answer

DataMapper Redis: can't find child from parent, only parent from child

I'm using DataMapper with the redis adapter in a Ruby library. I have these classes defined: class Zone include DataMapper::Resource property :id, String, :key => true, :unique_index => true, :default => lambda { |x,y| UUID.new.generate } …
lightyrs
  • 2,809
  • 2
  • 29
  • 32
0
votes
2 answers

Undefined method opts_from_validator_args

I just tried updating a project to use DataMapper 1.2 (from 1.1) and now I'm getting this error: /home/joe/.rvm/gems/ruby-1.9.2-p290@marketplace-admin/gems/dm-core-1.2.0/lib/dm-core/model/relationship.rb:372:in `method_missing': undefined method…
mltsy
  • 6,598
  • 3
  • 38
  • 51
0
votes
1 answer

Link shorthand application in Sinatra

This was my first Sinatra project - link shortener but I am stuck with some errors and to be honest sinatra's built-in debugger tells me literally nothing. I would like you to give me a clue or suggest a solution to problem.…
metrampaz
  • 663
  • 1
  • 6
  • 12
-1
votes
3 answers

How to get count of the sql search query?

How to get count of the sql search query $u = new user(); $sql = "SELECT a.id FROM `accounts` AS a LEFT JOIN `users` AS u ON a.id = u.id WHERE a.id IS NOT NULL "; $gender = $this->input->post('gender'); if($gender != NULL) { $sql .= "AND…
Yahiya
  • 761
  • 4
  • 15
1 2 3
75
76