AshDispatch.Resources.Notification.Base (AshDispatch v0.5.1)
View SourceProvides the base DSL for Notification resources.
This module exports a __using__ macro that consuming apps can use to create
their own Notification resource with a user relationship.
Usage
defmodule MyApp.Notifications.Notification do
use AshDispatch.Resources.Notification.Base,
repo: MyApp.Repo,
domain: MyApp.Notifications,
extensions: [AshTypescript.Resource]
# Optional: TypeScript type configuration
typescript do
type_name("Notification")
end
# Add your User relationship
relationships do
belongs_to :user, MyApp.Accounts.User do
source_attribute :user_id
destination_attribute :id
allow_nil? false
public? true
define_attribute? false # Base already defines user_id
end
end
endOptions
:repo- (required) Ecto repo module:domain- (required) Ash domain:extensions- Additional Ash extensions (e.g.,[AshTypescript.Resource]):table- Postgres table name. Defaults to"notifications". Override when the consumer app already owns that table for a legacy notification system and ash_dispatch needs to coexist (e.g.,table: "dispatch_notifications").