Ash FrameworkAF
Ash Framework5mo ago
6 replies
Abu kumathra

Aggregates based on resources keep failing

defmodule YourApp.Poetry.Topic do
  alias YourApp.Poetry.Poem

  use Ash.Resource,
    domain: YourApp.Poetry,
    data_layer: AshPostgres.DataLayer

  require Ash.Query

  postgres do
    table "topics"
    repo YourApp.Repo
  end

  actions do
    defaults [:create, :read, :update, :destroy]
  end

  attributes do
    uuid_v7_primary_key :id
    attribute :name, :string, allow_nil?: false
    attribute :slug, :string
    attribute :description, :string

    timestamps()
  end

  aggregates do
    # count :verse_count, :verses

    count :poem_count, Poem do
      filter expr(fragment("? = ANY(topics)", parent(name)))
    end
  end

  identities do
    identity :unique_name, [:name]
    identity :unique_slug, [:slug]
  end
end


the error is the following
Was this page helpful?