Skip to content

Instantly share code, notes, and snippets.

@gioele
Last active March 9, 2017 11:20
Show Gist options
  • Save gioele/25ec39e11bb92f78d58aeba447b8fc00 to your computer and use it in GitHub Desktop.
Save gioele/25ec39e11bb92f78d58aeba447b8fc00 to your computer and use it in GitHub Desktop.
require 'rom-repository'
require 'rom-sql'
db = ROM.container(:sql, 'sqlite::///tmp/foo.sqlite') do |c|
c.default.create_table(:users) do
primary_key :id
column :name, String, null: false
end
end
class UserRepo < ROM::Repository[:users]
commands :create, update: :by_pk
end
user_repo = UserRepo.new(db)
user = user_repo.create(name: 'Mel')
p user_repo.users.to_a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment