【发布时间】:2019-06-10 19:56:48
【问题描述】:
我很难在文档中找到有关如何执行以下 Ecto 查询的信息。我有一个模型 events,它与 customer 到 event.customer_id 的一对一映射。
在现有的查询管道中,我正在查询 events 并返回 events,它们只有一个不同的客户:
defp events_by_distinct_customer(query) do
query
|> distinct([e], e.customer_id)
end
除此之外,我还需要返回相关的客户对象而不是事件。我该怎么做,我要求做什么的方法/描述是什么?
【问题讨论】:
-
您只想要客户结果?