Created
March 25, 2015 13:27
-
-
Save solnic/5047c4972d7d5ad1ff8c to your computer and use it in GitHub Desktop.
ROM/AR "create" operation profiling
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 'active_record' | |
require 'hotch' | |
ActiveRecord::Base.establish_connection('postgresql://localhost/rom') | |
class User < ActiveRecord::Base | |
end | |
User.delete_all | |
Hotch() do | |
User.create(name: 'Jane Doe', email: '[email protected]', age: 21) | |
end |
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 'rom-sql' | |
require 'hotch' | |
ROM.setup(:sql, 'postgres://localhost/rom') | |
ROM.commands(:users) do | |
define(:create) do | |
result :one | |
end | |
end | |
rom = ROM.finalize.env | |
create_user = rom.command(:users).create | |
Hotch() do | |
create_user.call(name: 'Jane Doe', email: '[email protected]', age: 21) | |
end |
For anyone who finds this and wants to tinker, here's the setup:
$ createdb rom;
$ psql rom
[local] username@rom=# create table users (name varchar, email varchar, age int);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
doesn't matter, you can use released gems.