ROM::RA#group

Parsed documentation:
View on GitHub
Groups two relations in-memory using group operation

@example

  require 'rom'
  require 'rom/adapter/memory'

  setup = ROM.setup(memory: 'memory://localhost')

  setup.schema do
    base_relation(:users) do
      repository :memory

      attribute :user_id
      attribute :name
    end

    base_relation(:tasks) do
      repository :memory

      attribute :user_id
      attribute :title
    end
  end

  setup.relation(:tasks)

  setup.relation(:users) do
    def with_tasks
      in_memory { group(join(tasks), tasks: [:title]) }
    end
  end

  rom.relations.users.insert user_id: 1, name: 'Piotr'
  rom.relations.tasks.insert user_id: 1, title: 'Work'
  rom.relations.tasks.insert user_id: 1, title: 'Relax'

  rom.relations.users.with_tasks.to_a
  => [{ user_id: 1, name: "Piotr",
        tasks: [{ title: "Relax" }, { title: "Work" }] }]

@api public
Suggestions:
Please help! Open an issue on GitHub if this assessment is incorrect.