rom-sql
rom-sql copied to clipboard
Document custom datasets in rom-sql
There's no information about overridding dataset
using a block, ie:
require 'rom-sql'
rom = ROM.container(:sql, 'sqlite::memory') do |config|
config.gateways[:default].create_table :users do
primary_key :id
column :name, String
column :email, String
end
config.relation(:users) do
schema do
attribute :id, ROM::SQL::Types::Serial
attribute :name, ROM::SQL::Types::String
end
dataset do |rel|
select(*rel.schema.attributes.keys).order(:id)
end
end
end
rom.relations[:users].insert(name: 'Jane')
puts rom.relations[:users].first.inspect