Ash Elixir

AE

Ash Elixir

Join the community to ask questions about Ash Elixir and get answers from other members.

Join

support

showcase

today-i-learned

How to do polymorphic relationships, but with only 1 table?

Apologies if this has been answered before, but I couldn't find it in the search function. I want to create a table called transactions with the following columns: ```...

Nested form error - using create when I (think I) want update?

I have a nested form that has been working wonderfully to edit a Site and its related resources, and now I'm attempting to manage the Users who will be permissioned to use the Site as well. When I click to do my add_form for Users, I get a crash with: ``` [error] GenServer #PID<0.25850.0> terminating...

Load relationships on inserted ressource

I was wondering if there was a way to load relationships by default on an inserted ressource after a successful submit of a for_create form? The goal here is to simply append that newly inserted ressource to a list afterwards, but I need some relationships to be loaded on that ressource. I know I can do it manually, but I was wondering if there was a way to define some defaults "load" somewhere? Thanks a lot in advance 🙂...

AshStateMachine transitions from/to multiple states and no default initial state

Is there a way I can pass an array to from: and to:? Right now for the latter case it only makes sense if I can explicitly pass the state to transition to in the change builtin. Can I not specify a default initial state, and simply require that it be one of a set of initial states and not be nil? Tagging this Core for now....

ash_admin update to Surface 0.10.0

Is the update of ash_admin to surface 0.10.0 mentioned @ https://github.com/ash-project/ash_admin (2 days ago) available in hex.pm? If not, what would be the best way to update to fix for Surface 0.10.0. Getting the form macro expansion problem at compile time. Thanks for your help.

How to compare a seed and loaded resource?

I thought strip_metadata() would make the comparable ```elixir user = Ash.Seed.seed!(%User{...}) loaded_user = User.get_by_id!(user.id) |> Ash.Test.strip_metadata()...

Filter a change by action_type

I have a change that I want to apply to all the resource actions that are of type create, update and destroy. Looking at the Ash.Resource.Validation.Builtins I can only see the action_is/1 option which allows me to specific an action by name, but I can't find any action_type/1 options or something similar. Is that not possible?...

Use change manage_relationship without argument in create action.

I have a resource called User which has a has_one relationship with another resource called ImpersonatePermissions. When I create a new user, I want to also create a new in the impersonate_permissions table. To do that, I believe that I need to use manager_relationship. I was able to make this work with a custom change function: ```elixir...

Multi-Location + Multi-Tenant Read Replica

So we have a fairly complex requirement that we are hoping to solve via schema-based multi-tenancy and PG read replicas. As you can see from the diagram, we want to host the app in the cloud + 2 onsite locations matched to tenants. We would like to leverage read replicas to enable shared reads & local tenant writes in the event of internet/power outages at one of the on-site locations. Are there any immediately obvious problems with this idea, or does it seem feasible?...
No description

Multiple filters giving unexpected result

Say I have a data model similar to this: ```elixir defmodule Ht.Org do has_many :accounts, Ht.Account ...

Create relationship with itself

How can we add a relationship from some resource to itself? For example, let's say I have a User resource and I add a feature that an user can create another user, meaning that I want to add a field called created_by and created_by_id which is also an User...

Migration generator splitting composite primary keys

Before, I believe the recommendation was to do many_to_many relationships like so: ```elixir relationships do belongs_to :resource_a, App.ResourceA, primary_key?: true, allow_nil?: false belongs_to :resource_b, App.ResourceB, primary_key?: true, allow_nil?: false...

Reading Tenant ETS resources returns empty array

I am trying to read a tenanted ets resource but always getting empty list when trying to read, though creates are "successful". Below is my IEX session ``` Timshel.Ash.EtsComponent |> Ash.Changeset.for_create(:create, %{root: true}, tenant: "7473fdbc-4f04-4bbf-bf1f-c9721ebd18b6") |> Timshel.Ash.Api.create!() #Timshel.Ash.EtsComponent<...

Ash-Postgres and uuidv7

This might be an Ecto question. If I add a Postgres function uuidv7(), can Ash use it when creating new resource instances? If not, could Ash use such a function in Elixir (that would probably be faster anyway).

no FunctionClause matching when loading calculation

Hi, somewhere between this commit de943509f73ff0c6ef3749feb3cc6ab6e4d99d2d and now, I started getting an error in one of my graphql queries. ``` [error] Task #PID<0.6039.0> started from #PID<0.6032.0> terminating ** (Ash.Error.Unknown) Unknown Error...

guide for using Ash.Flow and multi step user flow with retries.

Hi Jack. Thanks for the good work you have put so far.
I was looking at Ash.Flow and the step DSL feels what i Might need. Here is the Use case in detail: ...

Resource's DSL "metric" actions

Hi @Zach Daniel, related to yesterday's question (https://discord.com/channels/711271361523351632/1097912088296443904) I got a new hint: we're trying a full-spread ash adoption on our internal project and we're trying to use only resource's code-interfaces everywhere, but for yesterday count/1 I've to call api module directly. What about the idea of a new kind of action supported by ash resource's DSL for defining resource's metrics methods in a declarative way? ...

Refresh "calculations" during form.validate

This question is kind of similar to https://discordapp.com/channels/711271361523351632/1071883200378445854/1071883200378445854 However, that example is a simple calculation involving two of the readily available form fields, whereas mine isn't as simple in that one of the inputs needs an aggregation of counts from an embedded array field as shown below. I want to be able to display the remaining count of an item which would decrease as the user increases the usage count. ``` calculate :item_remaining_count,...

`mix ash_postgres.generate_migrations` key `:table` not found

``` mix ash_postgres.generate_migrations Extension Migrations: No extensions to install...

Identity on two attributes causing errors

I have an identity on two attributes (context, and token). I would expect this to require a unique context <> token. But it's not allowing duplicate contexts. Here's my resource: ```elixir...