X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=src%2Fdb%2Fpostgres%2Findex.js;h=5899a26fb436fd7a2bd708cfa1d3f129b350a346;hb=8599aa8d2706b9fcf4cdecb663e5c9204989bae1;hp=54c6e9b72ba2ccee85078926113fcc2dea33c08d;hpb=b0103b0d496262c438b40bc20304081dbfe41e73;p=squeep-indie-auther diff --git a/src/db/postgres/index.js b/src/db/postgres/index.js index 54c6e9b..5899a26 100644 --- a/src/db/postgres/index.js +++ b/src/db/postgres/index.js @@ -48,7 +48,7 @@ class DatabasePostgres extends Database { if (queryLogLevel) { const queryScope = _fileScope('pgp:query'); pgpInitOptions.query = (event) => { - this.logger[queryLogLevel](queryScope, '', { ...common.pick(event, ['query', 'params']) }); + this.logger[queryLogLevel](queryScope, '', { ...common.pick(event || {}, ['query', 'params']) }); }; } @@ -59,7 +59,7 @@ class DatabasePostgres extends Database { }; // 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 = common.camelfy(prop); @@ -72,7 +72,7 @@ class DatabasePostgres extends Database { } if (queryLogLevel) { // 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 }); } };