11import { open } from 'sqlite' ;
2- import * as sqlite3 from 'sqlite3' ;
3- import { Pool } from 'pg' ;
42import { EventEmitter } from 'events' ;
53import { isJsonObject } from 'tiny-essentials' ;
64
5+ import { pg , sqlite3 } from './Modules.mjs' ;
76import PuddySqlQuery from './TinySqlQuery.mjs' ;
87
9- const { Database } = sqlite3 ;
10-
118/** @typedef {import('pg').Pool } PgPool */
129/** @typedef {import('sqlite').Database } SqliteDb */
1310
@@ -602,7 +599,7 @@ class PuddySqlInstance {
602599 /** @type {SqliteDb } */
603600 this . #db = await open ( {
604601 filename : filePath ,
605- driver : Database ,
602+ driver : sqlite3 . Database ,
606603 } ) ;
607604
608605 // Set SQL methods (all, get, run)
@@ -626,7 +623,8 @@ class PuddySqlInstance {
626623 * @throws {Error } If a SQL engine has already been set for this instance.
627624 */
628625 setSqlite3 ( db ) {
629- if ( ! ( db instanceof Database ) ) throw new Error ( 'Invalid type for db. Expected a Sqlite3.' ) ;
626+ if ( ! ( db instanceof sqlite3 . Database ) )
627+ throw new Error ( 'Invalid type for db. Expected a Sqlite3.' ) ;
630628 if ( ! this . #sqlEngine) {
631629 this . #sqlEngine = 'sqlite3' ;
632630
@@ -767,7 +765,7 @@ class PuddySqlInstance {
767765 async initPostgre ( config ) {
768766 if ( ! this . #sqlEngine) {
769767 /** @type {PgPool } */
770- this . #db = new Pool ( config ) ;
768+ this . #db = new pg . Pool ( config ) ;
771769
772770 // Set up the SQL methods (all, get, run)
773771 this . setPostgre ( this . #db) ;
@@ -792,7 +790,7 @@ class PuddySqlInstance {
792790 * @throws {Error } If a SQL engine is already set for this instance.
793791 */
794792 setPostgre ( db ) {
795- if ( ! ( db instanceof Pool ) ) throw new Error ( 'Invalid type for db. Expected a PostgreSQL.' ) ;
793+ if ( ! ( db instanceof pg . Pool ) ) throw new Error ( 'Invalid type for db. Expected a PostgreSQL.' ) ;
796794 if ( ! this . #sqlEngine) {
797795 this . #sqlEngine = 'postgre' ;
798796
0 commit comments