Delete command both with id and delete all


#1

Let’s say I have repository like this

require 'rom-repository.'

class UserRepo < ROM::Repository[:users]
  commands :create, update: :by_pk, delete: :by_pk
end

As you can see, now I can only do delete action only if I provide some ID. Is there a way to make this repository also have a capability to do delete all action? I’ve already tried to pass delete command, to commands method like this:

require 'rom-repository.'

class UserRepo < ROM::Repository[:users]
  commands :create, :delete, update: :by_pk, delete: :by_pk
end

But this still doesn’t work.

Thanks in advance
Opan Mustopah


#2

You can just do users.delete. Command macros in repos is just a convenience so that people can have common CUD methods available automatically.


#3

Ah yes, it’s working now. I swear I try similar to this, but it didn’t work yesterday. Thank you so much.