【发布时间】:2018-01-01 10:44:10
【问题描述】:
所以我读到了Ecto.Query.API.map/2 函数,我有一个必须使用它的场景。
查询是这样的:
from p in model,
where: p.id == 1,
select: map(p, [:id, :inserted_by, customer: [:id, :first_name]])
所以代替硬编码的id 和inserted_by 以及id 和first_name。我想在这样的列表中使用动态值
[:id, :inserted_by, :first_name]
我尝试通过将列表保存在变量中来使用^ 运算符。但它给出了错误cannot use outside of match clause
如何更改动态值的查询?
像这样
select: map(p, [^dynamic_value, customer: ^dynamic_value])
谢谢。
【问题讨论】:
标签: elixir phoenix-framework ecto