📜  ecto order by in preload - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:44.890000             🧑  作者: Mango

代码示例1
def get_member_2!(id) do
  query =
    from(
      p in Member,
      where: p.id == ^id,
      select: p,
      preload: [
        :avatar,
        activities:
          ^from(
            a in Activity,
            order_by: [desc: a.inserted_at]
          )
      ]
    )

  Repo.one!(query)
end