Created
October 13, 2011 23:20
-
-
Save jeffreybasurto/1285812 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'data_mapper' | |
# so we can see how long the database hits take. | |
DataMapper::Logger.new($stdout, :debug) | |
#DataMapper.setup(:default, "sqlite://#{File.expand_path(File.dirname(File.expand_path(__FILE__)) + '/data.db')}") | |
DataMapper.setup(:default, 'sqlite::memory:') | |
class Entry | |
include DataMapper::Resource | |
property :id, Serial | |
property :field, Integer | |
end | |
DataMapper.finalize # finalizes changes to model structure for database. | |
DataMapper.auto_migrate! # structures database to fit the model | |
# create 5000 entries | |
5000.times { Entry.create } | |
# just access the field of a single entry | |
Entry.first.field | |
# does nothing but access each field | |
Entry.all.each &:field | |
# update a single field to a new value. | |
Entry.first.update({:field=>99999}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment