问题描述
假设我们有以下模式:
schema "organization" do
embeds_one :details,Detail
timestamps()
end
# Detail schema
embedded schema do
field :name,:string
field :description,:string
end
details
字段作为jsonb字段存储在数据库中。
现在让我们说我想按组织名称查询组织,当前唯一可以使用的方法是使用片段:
Organization
|> where([org],fragment("details->>'name' = ?",^organization_name))
|> Repo.one()
有没有内置的方式可以执行此操作而无需使用片段?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)