Can't figure out how to update/delete records by conditions with Hanami::Repository.
For example, there are these tables: users
and clients
.
Users have:
deleted_at
column, for marking user as deletedclient_id
column, as foreign key onclients
table
How can I update user by id
, only if record not marked as deleted, and scoped by specific client?
Here is the pseudo code:
Users
.joins(:clients)
.where('clients.id = ?', client_id)
.where(deleted_at: nil)
.update(new_attributes)