Sha256: 303159e29fc5647ea0e4c5b95c8d83cc9bc2f6db0553d44ad7c0d18366cdc961

Contents?: true

Size: 394 Bytes

Versions: 1

Compression:

Stored size: 394 Bytes

Contents

# frozen_string_literal: true

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

  def find_with_comments(id)
    record = base
      .includes(:user)
      .includes(comments: :user)
      .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.5 test/dummy/app/repositories/article_repository.rb