@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 +5 -1
- package/lib/db/index.js +8 -1
- package/package.json +1 -1
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
|
-
|
|
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