Questions tagged [ruby-datamapper]

DataMapper is a Object Relational Mapper written in Ruby. It implements an architectural pattern with the same name (with some changes).

Key features of Datamapper:

  • query chaining (delaying actual talking to a DB until necessary)
  • bulk loading of several data rows with one query
  • very abstract design allowing non-SQL adapters
  • lazy loading of large fields

Home page http://datamapper.org/

242 questions
0
votes
1 answer

ruby DataMapper Object query

so I have a Class => #9} @signature_metrics={"Alert [1:485:4]"=>9} @src_ips={"93.21.29.12"=>9,"0.0.0.0",3} @dst_ips={"10.15.255.135"=>9} @created_at=Sat, 04 Mar 2017 17:31:59 UTC +00:00 @updated_at=Sat, 04 Mar 2017 18:02:02 UTC +00:00> =>…
Mark Ruth
  • 23
  • 6
0
votes
0 answers

Parallel POST requests to DB with Ruby/DataMapper

I'am trying to implement kind of a matchmaking REST service for the game. My matchmaking table is simple as ID (Serial) Client_Name_1 (String) Client_Name_2 (String) Basic idea is that when client sends me his "Name" I check if there is a row…
0
votes
1 answer

Should I use DataMapper entities only for persistence purposes?

I'm creating a non-Rails application and using DataMapper as ORM. For entities which will be mapped to SQL tables I declare classes which include DataMapper::Resource. The question is. Is it okay to use the instances of these classes as plain…
RhinoLarva
  • 735
  • 10
  • 16
0
votes
1 answer

Order BY diffrence of two columns using DataMapper

I have a mysql table. It contains 2 Column (startdate,enddate) Both are of DateTime type Using sql select * from ABC order by (enddate-startdate) DESC; same thing i want in datamapper...but i m not able to do it Plz help
Shubham Agrawal
  • 559
  • 6
  • 15
0
votes
1 answer

Use Geocoder with Sinatra and DataMapper

I'm attempting to use the Geocoder gem with a DataMapper model in a Sinatra application. environment.rb: require 'rubygems' require 'bundler/setup' require 'dm-core' require 'dm-timestamps' require 'dm-validations' require 'dm-aggregates' require…
craig
  • 25,664
  • 27
  • 119
  • 205
0
votes
0 answers

Datamapper unable to find table

I have an app running on my Raspberry Pi with Postgresql 9.1. My first iteration was to add weather records into a table called "Weathers". That was successful. My next iteration is to use psychopg2 to write records from Python into a different…
sam452
  • 1,281
  • 3
  • 20
  • 33
0
votes
1 answer

Activerecord/Datamapper - Have one child belong to many parents

How would you set up an activerecord/datamapper association for the following scenario: A user creates a "bookshelf" which has many books(a book object just has an isbn that is used to query an api, and has_many review objects associated with it).…
0
votes
1 answer

Transfer data from one database to another with Datamapper

I have two repositories set up within data mapper as follows: DataMapper.setup(:default, "sqlite://path/to/db1") DataMapper.setup(:another, "sqlite://path/to/otherdb") Lets say I have a model Foo that they both share a schema for. This is the…
Omar Darwish
  • 1,536
  • 2
  • 15
  • 23
0
votes
1 answer

Sinatra: Trouble with associating class instances having DataMapper One-To-Many-Through relation

I'm trying to build an admin backend for a cms. I have several model classes, and two of them are Post and Tag. They are connected through Tagging class. Post model class Post include DataMapper::Resource property :id, Serial …
marmeladze
  • 6,468
  • 3
  • 24
  • 45
0
votes
1 answer

Sinatra: NameError at '/route', undefined local variable or method

I'm trying to build an admin backend for a cms website. this is the structure of my application ├── app.rb ├── Gemfile ├── models │   └── models.rb ├── routes │   └── routes.rb └── views ├── categories.erb ├── # ... other view files app.rb…
marmeladze
  • 6,468
  • 3
  • 24
  • 45
0
votes
1 answer

Datamapper "Model.all()" method creates 3 selects and not selecting the right fields

I've started to use Datamapper with Padrino and i have some weird issue. The issues is explained below: 1.The code: content_type :json @fonts = Font.all(:fields=>[:id,:name,:class_name]) @fonts.to_json Datamapper executes 3 queries and return…
Yaniv Vova Alterman
  • 1,660
  • 1
  • 13
  • 11
0
votes
1 answer

Datamapper not saving ID, LocalJumpError - no block given

I recently refactored my DataMapper code, slowly rolling it out, and got it working on one database, but now I'm encountering problems when rolling it out to my expense database. Couldn't find the answer anywhere, and I've tried lots of fiddling. I…
Joe
  • 273
  • 5
  • 17
0
votes
1 answer

Ruby/Sinatra/Datamapper - Iterate through (and puts content of property) of datamapper collection

https://github.com/emilysas/Chitter I'm using DataMapper to make a mock of twitter. I have a model called Peep (Tweet). And I want to be able to show all the tweets via an erb. If I use <%= Peep.first.content if Peep.first %> Then I get the content…
Emily
  • 29
  • 5
0
votes
1 answer

In data_mapper, what is the best way to update a record or create a new one if it doesn't exist?

I'm using data_mapper in my own sinatra project. So, what is the best way to update a record or create a new one with initial value if it doesn't exist? E.g., I have a model like class Model include DataMapper::Resource property :id, Serial …
Papulatus
  • 677
  • 2
  • 8
  • 18
0
votes
1 answer

Ruby Sinatra Datamapper/database confusion

I'm confused as to how database relationship works. Say I have a Border Crossing('crossing'), which has two Directions('north', 'south'), each of which direction has 2 types of lanes ('normal','fast'), each of which lane has 2 metrics (=data)…
cannotcompute
  • 397
  • 4
  • 17