class ReeDaoAggTest::AggUsersWithDto

def author_opts

def author_opts
  { to_dto: -> (author) { ReeDaoAggTest::AuthorDto.new(author) }}
end

def books_opts

def books_opts
  {
    to_dto: -> (book) { ReeDaoAggTest::BookDto.new(book) },
    setter: -> (item, child_index) {
      item.set_books(child_index[item.id] || [])
    }
  }
end

def call(ids_or_scope, **opts)

def call(ids_or_scope, **opts)
  agg(users, ids_or_scope, **opts) do
    belongs_to :organization
    has_many :books, -> { books_opts } do
      has_one :author, -> { author_opts }
      has_many :chapters, -> { chapters_opts }
    end
  end
end

def chapters_opts

def chapters_opts
  { to_dto: -> (chapter) { ReeDaoAggTest::ChapterDto.new(chapter) }}
end