if (event && event.query && event.query.startsWith('NOTIFY')) {
return;
}
- this.logger[queryLogLevel](_fileScope('pgp:query'), '', { ...common.pick(event, ['query', 'params']) });
+ this.logger[queryLogLevel](_fileScope('pgp:query'), '', { ...common.pick(event || {}, ['query', 'params']) });
};
}
// Log errors
pgpInitOptions.error = (err, event) => {
this.logger.error(_fileScope('pgp:error'), '', { err, event });
+
+ // TODO: close connection on err.code === '57P03' database shutting down
};
// Deophidiate column names in-place, log results
- pgpInitOptions.receive = (data, result, event) => {
+ pgpInitOptions.receive = ({ data, result, ctx: event }) => {
const exemplaryRow = data[0];
for (const prop in exemplaryRow) {
const camel = Database._camelfy(prop);
return;
}
// Omitting .rows
- const resultLog = common.pick(result, ['command', 'rowCount', 'duration']);
+ const resultLog = common.pick(result || {}, ['command', 'rowCount', 'duration']);
this.logger[queryLogLevel](_fileScope('pgp:result'), '', { query: event.query, ...resultLog });
}
};