我正在使用nodejs创建一个API,尝试编辑带有邮递员错误的数据时遇到问题:绑定消息提供7个参数,但是准备好的语句“”需要8个
像这样:
{ error: bind message supplies 7 parameters, but prepared statement "" requires 8
at Connection.parseE (D:\server\IIS\backend_iis\node_modules\pg\lib\connection.js:545:11)
at Connection.parseMessage (D:\server\IIS\backend_iis\node_modules\pg\lib\connection.js:370:19)
at Socket.<anonymous> (D:\server\IIS\backend_iis\node_modules\pg\lib\connection.js:113:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:594:20)
name: 'error',
length: 147,
severity: 'ERROR',
code: '08P01',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'src\\backend\\tcop\\postgres.c',
line: '1504',
routine: 'exec_bind_message' }
这是nodejs中的查询模型
const editN = (payload) => { //payload being a parameter that needed to run query, each $1 (parameter) is being represented by the payload respectively
return pool.query('UPDATE berita SET (title, content, category, link_image, images, update_at, update_by) = (COALESCE($1, title), COALESCE($2, content), COALESCE($3, category), $4, $5, $6, $7) WHERE id = $8', payload)
}
有人能找到解决我问题的方法吗?
提前谢谢