@toxplanet/pegasus-sdk 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/connection.js CHANGED
@@ -195,7 +195,11 @@ class PegasusConnection {
195
195
 
196
196
  async query(sql, params) {
197
197
  const pool = this.getPostgresClient();
198
- return pool.query(sql, params);
198
+ const start = Date.now();
199
+ logInfo('pegasus-sdk', `[SQL] ${sql}${params ? ` -- params: ${JSON.stringify(params)}` : ''}`);
200
+ const result = await pool.query(sql, params);
201
+ logInfo('pegasus-sdk', `[SQL] rowCount: ${result.rowCount} duration: ${Date.now() - start}ms`);
202
+ return result;
199
203
  }
200
204
 
201
205
  async getClient() {
package/lib/db/index.js CHANGED
@@ -1,8 +1,15 @@
1
1
  const { drizzle } = require('drizzle-orm/node-postgres');
2
+ const { logInfo } = require('@toxplanet/tphelper/logging');
2
3
  const schema = require('./schema');
3
4
 
5
+ const logger = {
6
+ logQuery(query, params) {
7
+ logInfo('pegasus-sdk', `[SQL] ${query}${params?.length ? ` -- params: ${JSON.stringify(params)}` : ''}`);
8
+ }
9
+ };
10
+
4
11
  function getDrizzle(pgPool) {
5
- return drizzle(pgPool, { schema });
12
+ return drizzle(pgPool, { schema, logger });
6
13
  }
7
14
 
8
15
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toxplanet/pegasus-sdk",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "SDK for migrating chemical data to Pegasus PostgreSQL + OpenSearch architecture with Elasticsearch client compatibility",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",