@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.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1508,7 +1508,9 @@ declare class PsqlTransaction extends PsqlConnection {
|
|
|
1508
1508
|
clientConfig: ClientConfig;
|
|
1509
1509
|
client: Client;
|
|
1510
1510
|
private beginTransactionPromise;
|
|
1511
|
+
private connectPromise;
|
|
1511
1512
|
constructor(clientConfig: ClientConfig);
|
|
1513
|
+
close(): Promise<void>;
|
|
1512
1514
|
private beginTransaction;
|
|
1513
1515
|
rollback(): Promise<QueryResult<QueryResultRow>>;
|
|
1514
1516
|
commit(): Promise<QueryResult<QueryResultRow>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1508,7 +1508,9 @@ declare class PsqlTransaction extends PsqlConnection {
|
|
|
1508
1508
|
clientConfig: ClientConfig;
|
|
1509
1509
|
client: Client;
|
|
1510
1510
|
private beginTransactionPromise;
|
|
1511
|
+
private connectPromise;
|
|
1511
1512
|
constructor(clientConfig: ClientConfig);
|
|
1513
|
+
close(): Promise<void>;
|
|
1512
1514
|
private beginTransaction;
|
|
1513
1515
|
rollback(): Promise<QueryResult<QueryResultRow>>;
|
|
1514
1516
|
commit(): Promise<QueryResult<QueryResultRow>>;
|
package/dist/index.js
CHANGED
|
@@ -2707,10 +2707,17 @@ var PsqlTransaction = class extends PsqlConnection {
|
|
|
2707
2707
|
super();
|
|
2708
2708
|
this.clientConfig = clientConfig;
|
|
2709
2709
|
this.client = new Client2(clientConfig);
|
|
2710
|
+
this.connectPromise = this.client.connect();
|
|
2710
2711
|
this.beginTransactionPromise = this.beginTransaction();
|
|
2711
2712
|
}
|
|
2713
|
+
async close() {
|
|
2714
|
+
if (this.client) {
|
|
2715
|
+
await this.client.end();
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2712
2718
|
async beginTransaction() {
|
|
2713
|
-
|
|
2719
|
+
await this.connectPromise;
|
|
2720
|
+
return this.client.query("BEGIN");
|
|
2714
2721
|
}
|
|
2715
2722
|
async rollback() {
|
|
2716
2723
|
return this.query("ROLLBACK");
|
|
@@ -2722,7 +2729,7 @@ var PsqlTransaction = class extends PsqlConnection {
|
|
|
2722
2729
|
return this.client.end();
|
|
2723
2730
|
}
|
|
2724
2731
|
async query(query, values) {
|
|
2725
|
-
await this.
|
|
2732
|
+
await this.connectPromise;
|
|
2726
2733
|
await this.beginTransactionPromise;
|
|
2727
2734
|
return this.client.query(query, values);
|
|
2728
2735
|
}
|