obsidian
obsidian
AEAsh Elixir
Created by obsidian on 5/31/2023 in #support
Is it possible to pass a map to args instead of a list of attributes in code_interface?
I'd like to pull off something like:
actions do
update :update_stats do
argument :stats, :map

Enum.map(arg(:stats), fn {key, value} ->
change set_attribute(key, value)
end)
end
end
actions do
update :update_stats do
argument :stats, :map

Enum.map(arg(:stats), fn {key, value} ->
change set_attribute(key, value)
end)
end
end
code_interface do

define :update_stats, args: [:stats]

end
code_interface do

define :update_stats, args: [:stats]

end
but I get the following error:
Compilation error in file lib/leaderboard/data/resources/wallet.ex ==
** (Protocol.UndefinedError) protocol Enumerable not implemented for {:_arg, :stats} of type Tuple
(elixir 1.14.4) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.14.4) lib/enum.ex:166: Enumerable.reduce/3
(elixir 1.14.4) lib/enum.ex:4307: Enum.map/2
lib/leaderboard/data/resources/wallet.ex:21: (module)
Compilation error in file lib/leaderboard/data/resources/wallet.ex ==
** (Protocol.UndefinedError) protocol Enumerable not implemented for {:_arg, :stats} of type Tuple
(elixir 1.14.4) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.14.4) lib/enum.ex:166: Enumerable.reduce/3
(elixir 1.14.4) lib/enum.ex:4307: Enum.map/2
lib/leaderboard/data/resources/wallet.ex:21: (module)
Is there a way to dynamically pass in args that you want to update on the resource? Or do you have to hard code the set_attributes? I'm trying to bypass the need to pass in each attribute in order every time. As their are many attributes and not all of them will be updated each time.
28 replies
AEAsh Elixir
Created by obsidian on 5/31/2023 in #support
Is there an example of defining a resource that is an external API that you are querying from?
I'm trying to wrap my head around modeling a resource that is an external API. Should you even do that?
5 replies
AEAsh Elixir
Created by obsidian on 5/31/2023 in #support
How do I make an attribute on a resource unique?
I believe Identities are the way to do it https://ash-hq.org/docs/guides/ash/latest/topics/identities But having trouble finding code examples.
6 replies