我正在尝试将 json-sql npm 模块与 postgres 一起使用。 但我什至无法进行选择。
我认为,问题在于来自 json-sql 的查询包含 $p1 而不是 $1。 我需要调整什么才能从 json-sql 获得类似 postgres 的查询?
我尝试使用 { dialect : 'postgresql' } 配置选项,但我仍然遇到问题。
作为以下代码的结果:
let userCompSql = jsonSql.build({
type: 'select',
fields: ['id'],
table: 'user_computers',
condition: {
'os_name' : params.osName,
'os_minor' : params.osVersionMinor
}})
我得到一个字符串 userCompSql:"select "id"from "user_computers"where "os_name"= $p1 and "os_minor"= 0;" 但是我想为我的 postgresql 数据库使用 $1 而不是 $p1。
最佳答案
这太简单了。只需配置 { namedValues: false }...
关于json - 如何在 postgresql 中使用 json-sql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47296194/