Can you group_by a query and get back the full structs in Ecto?

You can’t. And you don’t need to. Elixir gives you the same tools in its standard library, so you can get your data first

list = %SomeStruct{} |> Repo.all()

and then do the grouping afterwards.

list |> Enum.group_by(:some_prop)

Which results in something like

  5: [%SomeStruct{}, %SomeStruct{}],
  9: [%SomeStruct{}]
Published * Last updated