X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=src%2Fdb%2Fpostgres%2Findex.js;fp=src%2Fdb%2Fpostgres%2Findex.js;h=5899a26fb436fd7a2bd708cfa1d3f129b350a346;hp=54c6e9b72ba2ccee85078926113fcc2dea33c08d;hb=8d74fc28d91c47cdaab2f2d0f2e811d1feab18f9;hpb=b0103b0d496262c438b40bc20304081dbfe41e73 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 }); } };