11import { open } from 'sqlite' ;
22import * as sqlite3 from 'sqlite3' ;
3- import * as pg from 'pg' ;
3+ import { Pool } from 'pg' ;
44import { EventEmitter } from 'events' ;
55import { isJsonObject } from 'tiny-essentials' ;
66
77import PuddySqlQuery from './TinySqlQuery.mjs' ;
88
99const { Database } = sqlite3 ;
10- const { Client } = pg ;
1110
1211/** @typedef {import('pg').Pool } PgPool */
1312/** @typedef {import('sqlite').Database } SqliteDb */
@@ -544,7 +543,7 @@ class PuddySqlInstance {
544543 /**
545544 * Returns the raw database instance currently in use.
546545 *
547- * This gives direct access to the internal database connection (PostgreSQL `Client ` or SQLite3 `Database`),
546+ * This gives direct access to the internal database connection (PostgreSQL `Pool ` or SQLite3 `Database`),
548547 * which can be useful for advanced queries or database-specific operations not covered by this wrapper.
549548 *
550549 * @returns {SqliteDb|PgPool } The internal database instance, or `null` if not initialized.
@@ -756,19 +755,19 @@ class PuddySqlInstance {
756755 /**
757756 * Initializes a PostgreSQL client and sets up the SQL engine for this instance.
758757 *
759- * This method creates a new PostgreSQL `Client ` using the given configuration,
758+ * This method creates a new PostgreSQL `Pool ` using the given configuration,
760759 * connects to the database, and assigns the SQL engine behavior using `setPostgre()`.
761760 * It also attaches a `SIGINT` listener to gracefully close the database connection
762761 * when the process is terminated.
763762 *
764763 * @param {Object } config - PostgreSQL client configuration object.
765- * Must be compatible with the `pg` Client constructor.
764+ * Must be compatible with the `pg` Pool constructor.
766765 * @throws {Error } If a SQL engine is already initialized for this instance.
767766 */
768767 async initPostgre ( config ) {
769768 if ( ! this . #sqlEngine) {
770769 /** @type {PgPool } */
771- this . #db = new Client ( config ) ;
770+ this . #db = new Pool ( config ) ;
772771
773772 // Set up the SQL methods (all, get, run)
774773 this . setPostgre ( this . #db) ;
@@ -793,7 +792,7 @@ class PuddySqlInstance {
793792 * @throws {Error } If a SQL engine is already set for this instance.
794793 */
795794 setPostgre ( db ) {
796- if ( ! ( db instanceof pg . Pool ) ) throw new Error ( 'Invalid type for db. Expected a PostgreSQL.' ) ;
795+ if ( ! ( db instanceof Pool ) ) throw new Error ( 'Invalid type for db. Expected a PostgreSQL.' ) ;
797796 if ( ! this . #sqlEngine) {
798797 this . #sqlEngine = 'postgre' ;
799798
0 commit comments