Skip to content

Instantly share code, notes, and snippets.

@ashgti
Created June 21, 2009 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashgti/133351 to your computer and use it in GitHub Desktop.
Save ashgti/133351 to your computer and use it in GitHub Desktop.
#!ruby
require 'rubygems'
gem 'dm-core', '=0.10.0'
# gem 'dm-core', '=0.9.11'
require 'dm-core'
DataMapper::Logger.new(STDOUT, :all)
DataMapper.setup(:default, "mysql://root:password@localhost/db_testing")
class Car
include DataMapper::Resource
property :id, Serial
property :brand, String
property :year, Integer
property :color, String
end
Car.auto_migrate!
Car.create(:brand => 'Honda', :year => 2008, :color => 'blue')
Car.create(:brand => 'Toyota', :year => 2008, :color => 'red')
p Car.all(:brand => 'Toyota')
p Car.all(:year => 2008)
p Car.all(:year => 2008, :color.not => 'blue').all(:conditions => ['brand = ? OR brand = ?', 'Toyota', 'Honda'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment