@restura/core 0.1.0-alpha.16 → 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 +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2657,12 +2657,47 @@ var restura = new ResturaEngine();
|
|
|
2657
2657
|
// src/restura/sql/PsqlTransaction.ts
|
|
2658
2658
|
import pg4 from "pg";
|
|
2659
2659
|
var { Client: Client2 } = pg4;
|
|
2660
|
+
var PsqlTransaction = class extends PsqlConnection {
|
|
2661
|
+
constructor(clientConfig) {
|
|
2662
|
+
super();
|
|
2663
|
+
this.clientConfig = clientConfig;
|
|
2664
|
+
this.client = new Client2(clientConfig);
|
|
2665
|
+
this.connectPromise = this.client.connect();
|
|
2666
|
+
this.beginTransactionPromise = this.beginTransaction();
|
|
2667
|
+
}
|
|
2668
|
+
async close() {
|
|
2669
|
+
if (this.client) {
|
|
2670
|
+
await this.client.end();
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
async beginTransaction() {
|
|
2674
|
+
await this.connectPromise;
|
|
2675
|
+
return this.client.query("BEGIN");
|
|
2676
|
+
}
|
|
2677
|
+
async rollback() {
|
|
2678
|
+
return this.query("ROLLBACK");
|
|
2679
|
+
}
|
|
2680
|
+
async commit() {
|
|
2681
|
+
return this.query("COMMIT");
|
|
2682
|
+
}
|
|
2683
|
+
async release() {
|
|
2684
|
+
return this.client.end();
|
|
2685
|
+
}
|
|
2686
|
+
async query(query, values) {
|
|
2687
|
+
await this.connectPromise;
|
|
2688
|
+
await this.beginTransactionPromise;
|
|
2689
|
+
return this.client.query(query, values);
|
|
2690
|
+
}
|
|
2691
|
+
};
|
|
2660
2692
|
export {
|
|
2661
2693
|
HtmlStatusCodes,
|
|
2694
|
+
PsqlConnection,
|
|
2662
2695
|
PsqlPool,
|
|
2696
|
+
PsqlTransaction,
|
|
2663
2697
|
RsError,
|
|
2664
2698
|
SQL,
|
|
2665
2699
|
escapeColumnName,
|
|
2700
|
+
eventManager_default as eventManager,
|
|
2666
2701
|
insertObjectQuery,
|
|
2667
2702
|
isValueNumber2 as isValueNumber,
|
|
2668
2703
|
logger,
|