Skip to content

Automatically sets archive_related from ash_archival for all has_many, has_one, and many_to_many relationships.

Notifications You must be signed in to change notification settings

devall-org/ash_cascade_archival

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AshCascadeArchival

Automatically sets archive_related from ash_archival for all has_many, has_one, and many_to_many relationships.

Installation

Add ash_cascade_archival to your list of dependencies in mix.exs:

def deps do
  [
    {:ash_cascade_archival, "~> 0.1.0"}
  ]
end

Usage

defmodule Post do
  use Ash.Resource,
    data_layer: Ash.DataLayer.Postgres,
    extensions: [AshCascadeArchival]

  attributes do
    uuid_primary_key :id
    attribute :title, :string
  end

  relationships do
    belongs_to :author, Author

    has_many :comments, Comment
    has_many :post_tags, PostTag

    many_to_many :tags, Tag, through: PostTag
  end

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

For the example above, archive_related of ash_archival is automatically set as follows.

archive do
  archive_related [:comments, :post_tags]
end

License

MIT

About

Automatically sets archive_related from ash_archival for all has_many, has_one, and many_to_many relationships.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages