feat: add task definition

This commit is contained in:
Moritz Böhme 2025-04-04 20:30:20 +02:00
parent 0183675176
commit ddf42409d5
6 changed files with 45 additions and 4 deletions

7
lib/putzplan/tasks.ex Normal file
View file

@ -0,0 +1,7 @@
defmodule Putzplan.Tasks do
use Ash.Domain
resources do
resource Putzplan.Tasks.Definition
end
end

View file

@ -0,0 +1,31 @@
defmodule Putzplan.Tasks.Definition do
# This turns this module into a resource
use Ash.Resource, domain: Putzplan.Tasks
actions do
# Use the default implementation of the :read action
defaults [:read]
# and a create action, which we'll customize later
create :create do
accept [:description, :repetition_days]
end
end
# Attributes are the simple pieces of data that exist on your resource
attributes do
# Add an autogenerated UUID primary key called `:id`.
uuid_primary_key :id
attribute :description, :string do
allow_nil? false
public? true
end
attribute :repetition_days, :integer do
allow_nil? false
public? true
constraints min: 1
end
end
end