Arjun Bajaj
Arjun Bajaj
AEAsh Elixir
Created by Arjun Bajaj on 2/20/2023 in #support
Only change a few fields `ON CONFLICT` in an Upsert
Thanks!
6 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/18/2023 in #support
How do you set an attribute to the join resource when creating?
Yes, thanks!
26 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/18/2023 in #support
How do you set an attribute to the join resource when creating?
Thanks a lot for all your help @Zach Daniel! :ashley:
26 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/18/2023 in #support
How do you set an attribute to the join resource when creating?
For future readers, after setting attribute_writable? true on your join resource association, here's the final create function which works:
create :create do
accept [:name, :desc]
argument :user_id, :binary

change fn changeset, %{actor: actor} = _context ->
join = %{user_id: actor.id, role: :owner}
changeset |> Ash.Changeset.manage_relationship(:users_join_assoc, join, type: :create)
end
end
create :create do
accept [:name, :desc]
argument :user_id, :binary

change fn changeset, %{actor: actor} = _context ->
join = %{user_id: actor.id, role: :owner}
changeset |> Ash.Changeset.manage_relationship(:users_join_assoc, join, type: :create)
end
end
26 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/18/2023 in #support
How do you set an attribute to the join resource when creating?
that works! 🚀
26 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/18/2023 in #support
How do you set an attribute to the join resource when creating?
Input invalid: relationship user is required.
26 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/18/2023 in #support
How do you set an attribute to the join resource when creating?
That doesn't work either
26 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/18/2023 in #support
How do you set an attribute to the join resource when creating?
With :append_and_remove it gives an error record with role: :owner | user_id: "EF6DF726A6" not found. However, with :create instead, it gives this error: Input invalid: relationship user is required. I'm guessing this is complaining that the user on the join resource is not provided through here.
26 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/18/2023 in #support
How do you set an attribute to the join resource when creating?
I tried with users_join_assoc too, but then it sets that to an empty list.
26 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/18/2023 in #support
How do you set an attribute to the join resource when creating?
No such relationship users_join_relationship for resource Org
26 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/16/2023 in #support
Differences between ETS and Postgres
Thanks for all your help again!
17 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/16/2023 in #support
Differences between ETS and Postgres
That's another interesting thing I found about Ash. PlanetScale doesn't support foreign key constraints and has other limitations as they say it would not be possible to build their scalable architecture otherwise. However, I would be wary of not using FKs in production simply because I would be afraid of making an error in my code. But using Ash, since it abstracts away the data layer almost completely, I think a combination of the two would work surprisingly well for many applications.
17 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/16/2023 in #support
Differences between ETS and Postgres
That's a great idea, I can maybe try that as an experiment after a few weeks or something. I don't understand nearly enough of Ash to attempt it right now though. Like I haven't even ventured into aggregates and a bunch of other features! I'll keep you updated if I try it out.
17 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/16/2023 in #support
Differences between ETS and Postgres
As an aside, after watching your video on LiveView Mastery where you implement the Twitter clone, and listening to the Thinking Elixir, I was impressed by how Ash does queries in the most performant way possible. So I cloned the ash_postgres repo to see how big it is, and well, tokei shows there are almost 11k lines of code in the lib folder! My thinking to create a data layer for let's say PlanetScale was, we could clone it, make the necessary changes to connect it to MySQL, and then figure out all the code changes required until the tests pass. But if the ash_sql abstraction is possible, I'm sure that's a better route.
17 replies
AEAsh Elixir
Created by Arjun Bajaj on 2/16/2023 in #support
Differences between ETS and Postgres
that's fair. since its SQL I cannot expect it to work in ETS. So apart from that, Ash should most abstract away everything else.
17 replies