Ash FrameworkAF
Ash Framework7mo ago
4 replies
Sienhopist

Calculation returning array of strings

I have a calculation that returns an array of strings.
  calculations do
    calculate :name_variations, {:array, :string}, fn _, _ ->
      ["hello", "world"]
    end
  end


But when I load this calculation, I get back only 2 results from the query. The first has "hello" and the other "world".

Why don't I get all query results instead of the first 2 with each of them having the full list?
Solution
  calculations do
    calculate :name_variations, {:array, :string}, fn records, _ ->
      Enum.map(records, fn _ -> ["hello", "world"] end)
    end
  end
Was this page helpful?