Document custom datasets in rom-sql

Open
#362 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby, sql
Domain
documentation

Research direction

Start from the issue's ROM.container(:sql, ...) example and inspect the rom-sql documentation entry points for relation datasets. Document how a relation can override dataset with a block, including what the block receives and the resulting query behavior. Done means a newcomer can find and follow the documented custom-dataset example.

Written by the indexing model from the issue text.

Description

docsite help wanted

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
Dominant language
Ruby
Stars
220
Forks
97
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rom-rb/rom-sql

All issues in rom-rb/rom-sql

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.