Sha256: 642236c13fc92f8f3b8f016296ce05bf8b1d8cb21a2fefe7e9c727b601164210

Contents?: true

Size: 422 Bytes

Versions: 1

Compression:

Stored size: 422 Bytes

Contents

# frozen_string_literal: true

class ArticleRepository < Upgrow::Repository
  def all
    to_model(base.all.includes(:user_record))
  end

  def find_with_comments(id)
    record = base
      .includes(:user_record)
      .includes(comment_records: :user_record)
      .find(id)

    to_model(record)
  end

  def find_for_user(id, user:)
    record = base.find_by(id: id, user_id: user.id)
    to_model(record)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
upgrow-0.0.4 test/dummy/app/repositories/article_repository.rb