What about relations between repositories, for example:
Voldemar Duletskiy


Assume you have a model Disc and a disc has many songs, on the Song migration you would declare the disc_id as a foreign_key, and then on DiscRepository

class DiscRepository < Hanami::Repository
associations do
has_many :songs

def create_with_songs(data)

def find_with_songs(id)
aggregate(:songs).where(id: id).as(Disc).one

This way you will be able to call disc.songs although you won't have all the Rails methods like disc.songs.clear or disc.songs.where(title: 'My song) and that's because the songs method will return a simple array.

As you can se, we need to explicitly create methods that use the association in order to not bloat your repository with association methods when it's not needed.

Sorry for taking so long to reply, I was very busy lately.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.