const logger = new (winston.Logger)({
transports : [
new winston.transports.PostgreSQL({
connString : 'xxxxxxxxxxx',
schema : 'public',
//tableName : 'logEntry',
customSql:'INSERT INTO public."logEntry"(logLevel, msg, meta) VALUES ($1, $2, $3);',
})
];
});
数据未插入表中,我在控制台中收到警告:
Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
谁能告诉我这段代码有什么问题?
最佳答案
您需要定义一个错误处理程序来克服此错误消息,
logger.transports.PostgreSQL.on('error', err =>
console.log('Error while inserting data')
);
希望这对您有所帮助!
关于node.js - winston postgresql 自定义 sql/tableName 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46940176/