How can I delete a record by id?
Currently I can destroy a ticket with:
But I would like to be able to do it by ID:
My code:
Helpdesk.Api.destroy_support_ticket ticketHelpdesk.Api.destroy_support_ticket ticketBut I would like to be able to do it by ID:
Helpdesk.Api.destroy_support_ticket "5f63e748-68e0-4b7d-9030-47c38eb8e86e"Helpdesk.Api.destroy_support_ticket "5f63e748-68e0-4b7d-9030-47c38eb8e86e"My code:
defmodule Helpdesk.Support.Ticket do
# @link https://ash-hq.org/docs/guides/ash/latest/tutorials/get-started
# This turns this module into a resource
use Ash.Resource,
data_layer: Ash.DataLayer.Ets
actions do
# Add a set of simple actions. You'll customize these later.
defaults [:create, :read, :update, :destroy]
### ommitted code..
# @link https://ash-hq.org/docs/guides/ash/latest/code-interface
code_interface do
define :open_support_ticket, args: [:subject]
define :read_support_ticket, action: :read, get_by: [:id]
define :close_support_ticket, args: []
define :destroy_support_ticket, action: :destroy
end
enddefmodule Helpdesk.Support.Ticket do
# @link https://ash-hq.org/docs/guides/ash/latest/tutorials/get-started
# This turns this module into a resource
use Ash.Resource,
data_layer: Ash.DataLayer.Ets
actions do
# Add a set of simple actions. You'll customize these later.
defaults [:create, :read, :update, :destroy]
### ommitted code..
# @link https://ash-hq.org/docs/guides/ash/latest/code-interface
code_interface do
define :open_support_ticket, args: [:subject]
define :read_support_ticket, action: :read, get_by: [:id]
define :close_support_ticket, args: []
define :destroy_support_ticket, action: :destroy
end
end