错误节点JS提交PG缓冲区或ArrayBuffer

时间:2018-10-04 19:07:59

标签: node.js pg

我不知道原因,我在其他项目和相同的作品中有相同的代码。

错误:

  

buffer.js:481       抛出新的TypeError('“ string”必须是字符串,Buffer或ArrayBuffer');       ^

TypeError: "string" must be a string, Buffer, or ArrayBuffer
at Function.byteLength (buffer.js:481:11)
at module.exports.Writer.addCString (C:\xampp\htdocs\backend\src\modules\agent-collector\node_modules\buffer-writer\index.js:57:22)
at C:\xampp\htdocs\backend\src\modules\agent-collector\node_modules\pg\lib\connection.js:153:28
at Array.forEach (<anonymous>)
at Connection.startup (C:\xampp\htdocs\backend\src\modules\agent-collector\node_modules\pg\lib\connection.js:151:23)
at Connection.<anonymous> (C:\xampp\htdocs\backend\src\modules\agent-collector\node_modules\pg\lib\client.js:79:11)
at emitNone (events.js:106:13)
at Connection.emit (events.js:208:7)
at Socket.<anonymous> (C:\xampp\htdocs\backend\src\modules\agent-collector\node_modules\pg\lib\connection.js:62:10)
at emitNone (events.js:111:20)

代码:

const { Pool, Client } = require('pg');
require('../../config/config');

const client = new Client({
    user: user,
    host: host,
    database: database,
    password: password,
    port: port,
});

client.connect();

async function database (query) {
    let data = await client.query(query);
    await client.query('COMMIT');
    return data;
}

0 个答案:

没有答案