I'm having some trouble doing delete/update operations using joins on a repository.
I have Libraries that belong to Users and have many Books, like so:
class LibraryRepository < Hanami::Repository
  associations do
    belongs_to: user
    has_many :books
  end
class BookRepository < Hanami::Repository
  associations do
    belongs_to :library
  end
Now what I want to delete a book entry, but only if it belongs to the user library. I was trying to do that using the following query:
books.join(libraries).where(libraries[:user_id] => user_id).where(id: id).delete
But I get the following error:
Sequel::Error: Need multiple FROM tables if updating/deleting a dataset with JOINs
Any suggestions into how I could do such a query?
 
                        
I think Hanami do not support multiple from, but postgresql does