@restura/core 0.1.0-alpha.17 → 0.1.0-alpha.18

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/dist/index.mjs CHANGED
@@ -2662,10 +2662,17 @@ var PsqlTransaction = class extends PsqlConnection {
2662
2662
  super();
2663
2663
  this.clientConfig = clientConfig;
2664
2664
  this.client = new Client2(clientConfig);
2665
+ this.connectPromise = this.client.connect();
2665
2666
  this.beginTransactionPromise = this.beginTransaction();
2666
2667
  }
2668
+ async close() {
2669
+ if (this.client) {
2670
+ await this.client.end();
2671
+ }
2672
+ }
2667
2673
  async beginTransaction() {
2668
- return this.query("BEGIN");
2674
+ await this.connectPromise;
2675
+ return this.client.query("BEGIN");
2669
2676
  }
2670
2677
  async rollback() {
2671
2678
  return this.query("ROLLBACK");
@@ -2677,7 +2684,7 @@ var PsqlTransaction = class extends PsqlConnection {
2677
2684
  return this.client.end();
2678
2685
  }
2679
2686
  async query(query, values) {
2680
- await this.client.connect();
2687
+ await this.connectPromise;
2681
2688
  await this.beginTransactionPromise;
2682
2689
  return this.client.query(query, values);
2683
2690
  }