📜  预加载中的 Ecto order_by - 无论代码示例

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

代码示例2
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