Ash Framework

AF

Ash Framework

The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.

Join

support

showcase

today-i-learned

Identity for user email will not work during upsert

So, I added the following to my User resource: ```elixir identities do identity :unique_email, [:email] do...

Ash.Changeset.change_attribute before or after action

I have this in my seeds.exs file: ```elixir Accounts.User |> Ash.Changeset.new()...

Add nonce and/or OIDC to AshAuthentication

OIDC is built on top of oauth2 and is already implemented in Assent. Some providers, Netsuite in my case, (seem to) require a nonce, which Assent provides when creating a new strategy and passing nonce: true https://github.com/pow-auth/assent/blob/b591e5a714765770340f6cf81e54db29118e511b/lib/assent/strategies/oidc.ex#L49...

Alternative approach for aggregate of aggregate with group by

Assuming three resources: A has_many B has_many C, and a requirement to calculate, for each record A, the sum of distinct C.status values, grouped by C.status. I tried implementing this via the ash DSL, however I think I would need a few features not yet implemented such as "aggregate of aggregate" and "group by aggregate". Would a custom calculation and falling back to ecto be the best way forward?...

Many To Many Relationship Example

After reading https://www.ash-hq.org/docs/guides/ash/latest/topics/relationships.md#has-many and https://ash-hq.org/docs/dsl/ash/latest/ash-resource-dsl/relationships/many_to_many I am a little bit confused since the examples use different code. I am looking for a simple example which I can copy and paste. Something like a blog post which has multiple tags associated via a many to many relationship: ```elixir defmodule Example.Blog.Post do use Ash.Resource,...

How to Ash-idiomatically get all unique values of an attribute across all records?

App.Api.Item is a resource with an attribute :name. How can I go from the set of all records of Item (App.Api.Item |> App.Api.read!()) to a list of all unique values of the :name attribute in the most idiomatic way?...

Filling encrypted fields during user registration

I'm using Cloak to encrypt some fields of my user resource. I have a very similar setup as the one used in AshHQ. The field itself is configured in that way in the resource: ```elixir attributes do ......

Why my policy is always blocking the function call?

I want to add a policy to only accept calling the confirm (ash authentication email confirmation action) action when the actor confirmed_at is nil. To do that, I added: ```elixir...

Can I fetch a resource with `get :id`?

To fetch a resource by a specific id I use this code: ```elixir [post] = MyApp.Post |> Ash.Query.filter(id == "bc38fcb3-080d-46ba-834d-5as58d689sda")...

Nested aggregates

In my Product Data Management webapp I'm trying to build with Ash, I have the following resources with attributes and relatioships in App.Api that, combined, construct/define an Item. * Category: has a :code attribute * Family: belongs_to a Category (and also has a :name, etc.) * Variant: belongs_to a Variant, has a :code attribute...

Module Calculations: Concat example leads to Enum.map_join/3 error (separator argument missing)

I have the following 3 resources: ```elixir App.Api.Brand App.Api.Category App.Api.Family...

Another calculations query

I have 'Job' which is related to a 'Service' via another resource (not defined as a :through). I need a calculation that does something like ```elixir expr(status == ^JobStatus.completed() and order_service.service.track_weights == true and is_nil(weights)...

How do you invalidate/persist tokens with ash_authentication?

JWT tokens by itself are stateless, meaning that you can't invalidate them if you do not store them. Is there a way to do that with ash_authentication?...

Add additional inputs to registration in AshAuthPhoenix

Hello, as the title says I want to additional inputs to the registration form. I already added the additional field in the resource and I read the documentation about the Overrides but I don't understand how I should proceed from there: wich override I need to call? Edit: typo

How to run :request_password_reset_with_password action?

So, looking at my request_password_reset_with_password action. it expects a changeset of an actual record. But that would mean that I would need an changeset of the user I want to reset the password. How would I get that user if the whole point of doing the reset is because the user is not able to login to that user?...

Timezone handling in Ash

I'm using https://github.com/madeitGmbH/tz_datetime to store user entered local datetime as UTC datetime in the table, and convert it back to local time when reading. Does Ash have a built-in solution for making this type of timezone conversion easier?

Virtual field in Ash attribute

What's the Ash way to handle virtual fields often used for inputs that are not persisted?

Create has_one relationship with flexible resource type

is there a "best practice" for creating a has_one relationship with a flexible resource type? E.g. if I have the resources PrivateContact and PublicContact Is something like the following possible? `relationships do...

Any example of an ASH app running distributed?

I am looking for an open source project or a blog article that shows an app built with ASH that runs in distributed mode. If you know about one then please drop the link to it....

How can I delete a record by id?

Currently I can destroy a ticket with:
Helpdesk.Api.destroy_support_ticket ticket
Helpdesk.Api.destroy_support_ticket ticket
...