关于nodejs无法正常工作的预处理语句(使用node-postgres)

时间:2013-07-27 13:16:07

标签: node.js

我正在使用nodejs 0.10.12和最新版本的node-postgres模块。 我尝试使用预备语句,我有类似

的东西
var query = client.query(  {text:"insert into controller(c_name) values($1)", values:[ja]});
//ja is a var that contains user input came from the client side

query.on("error", function (error) {
console.log(error)});

query.on("end", function (result) {
console.log(result), client.end()});

我得到以下

{[error: permission denied for relation controller]
length: 116,
name: 'error',
severity: 'ERROR',
code: '42501',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
file: '.\\src\\backend\\catalog\\aclchk.c',
line: '3166',
routine: 'aclcheck_error'}
undefined

我承认我是节点和该模块的新手,所以我不知道如何解决这个问题。 有任何建议/提示吗?

非常感谢

1 个答案:

答案 0 :(得分:1)

传入的字符串是否大于c_name长度?

  

长度:116,

其次,您会看到code: '42501'应该是错误代码,您应该在node-postgres项目文档或来源中搜索。