我只是想在没有任何 ecto 设置的情况下使用 Postgrex,所以只是文档自述文件中的示例。
这是我的模块的样子:
defmodule Receive do
def start(_type, _args) do
{:ok, pid} = Postgrex.start_link(
hostname: "localhost",
username: "john",
# password: "",
database: "property_actions",
extensions: [{Postgrex.Extensions.JSON}]
)
Postgrex.query!(
pid,
"INSERT INTO actions (search_terms) VALUES ($1)",
[
%{foo: 'bar'}
]
)
end
end
当我运行我得到的代码时
** (RuntimeError) type `json` can not be handled by the types module Postgrex.DefaultTypes, it must define a `:json` library in its options to support JSON types
有什么我没有正确设置的吗?根据我在文档中收集的内容,我什至不需要该扩展行,因为默认情况下会处理 json。