Ecto json_agg for structs

With fragment("array_agg(?) table", table_rows) returning a list, and fragment("json_agg(?) table", table_rows) returning a %{key: value} map, is there an equivalent function/method to return a struct? ie: %Table{key: value}

I realize this might be asking for too much :slight_smile:

1 Like

Not really. However you could use embedded_many with schema for that.

You could sort of re-create this by json_agg all the columns and then using Repo.load to cast stuff.

1 Like