@hemia/db-connector 0.0.12 → 0.0.13
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.
|
@@ -3085,27 +3085,12 @@ class DrizzlePostgresConnector extends DrizzleSqlConnector {
|
|
|
3085
3085
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3086
3086
|
this.ensureConnected();
|
|
3087
3087
|
try {
|
|
3088
|
-
yield this.
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
yield this.connection `COMMIT`;
|
|
3092
|
-
}),
|
|
3093
|
-
rollback: () => __awaiter(this, void 0, void 0, function* () {
|
|
3094
|
-
yield this.connection `ROLLBACK`;
|
|
3095
|
-
})
|
|
3096
|
-
};
|
|
3097
|
-
try {
|
|
3098
|
-
const result = yield fn(txMock);
|
|
3099
|
-
yield this.connection `COMMIT`;
|
|
3100
|
-
return result;
|
|
3101
|
-
}
|
|
3102
|
-
catch (error) {
|
|
3103
|
-
yield this.connection `ROLLBACK`;
|
|
3104
|
-
throw error;
|
|
3105
|
-
}
|
|
3088
|
+
return yield this.db.transaction((tx) => __awaiter(this, void 0, void 0, function* () {
|
|
3089
|
+
return yield fn(tx);
|
|
3090
|
+
}));
|
|
3106
3091
|
}
|
|
3107
3092
|
catch (error) {
|
|
3108
|
-
console.error(error);
|
|
3093
|
+
console.error("Transaction Error:", error);
|
|
3109
3094
|
throw this.createDatabaseError(error);
|
|
3110
3095
|
}
|
|
3111
3096
|
});
|
|
@@ -3083,27 +3083,12 @@ class DrizzlePostgresConnector extends DrizzleSqlConnector {
|
|
|
3083
3083
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3084
3084
|
this.ensureConnected();
|
|
3085
3085
|
try {
|
|
3086
|
-
yield this.
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
yield this.connection `COMMIT`;
|
|
3090
|
-
}),
|
|
3091
|
-
rollback: () => __awaiter(this, void 0, void 0, function* () {
|
|
3092
|
-
yield this.connection `ROLLBACK`;
|
|
3093
|
-
})
|
|
3094
|
-
};
|
|
3095
|
-
try {
|
|
3096
|
-
const result = yield fn(txMock);
|
|
3097
|
-
yield this.connection `COMMIT`;
|
|
3098
|
-
return result;
|
|
3099
|
-
}
|
|
3100
|
-
catch (error) {
|
|
3101
|
-
yield this.connection `ROLLBACK`;
|
|
3102
|
-
throw error;
|
|
3103
|
-
}
|
|
3086
|
+
return yield this.db.transaction((tx) => __awaiter(this, void 0, void 0, function* () {
|
|
3087
|
+
return yield fn(tx);
|
|
3088
|
+
}));
|
|
3104
3089
|
}
|
|
3105
3090
|
catch (error) {
|
|
3106
|
-
console.error(error);
|
|
3091
|
+
console.error("Transaction Error:", error);
|
|
3107
3092
|
throw this.createDatabaseError(error);
|
|
3108
3093
|
}
|
|
3109
3094
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
|
2
2
|
import { PgTable } from 'drizzle-orm/pg-core';
|
|
3
|
-
import { DrizzleSqlConnector, DrizzleSelectOptions, DrizzleInsertOptions, DrizzleUpdateOptions, DrizzleDeleteOptions, DrizzleQueryOptions
|
|
3
|
+
import { DrizzleSqlConnector, DrizzleSelectOptions, DrizzleInsertOptions, DrizzleUpdateOptions, DrizzleDeleteOptions, DrizzleQueryOptions } from '../abstract/DrizzleSQLConnector';
|
|
4
4
|
import { CredentialsConnection } from '../types/CredentialsConnection';
|
|
5
5
|
export declare class DrizzlePostgresConnector extends DrizzleSqlConnector {
|
|
6
6
|
private readonly creds;
|
|
@@ -19,7 +19,7 @@ export declare class DrizzlePostgresConnector extends DrizzleSqlConnector {
|
|
|
19
19
|
update(entity: string, filter: Record<string, any>, data: Record<string, any>, options?: DrizzleUpdateOptions): Promise<number>;
|
|
20
20
|
delete(entity: string, filter: Record<string, any>, options?: DrizzleDeleteOptions): Promise<number>;
|
|
21
21
|
query<T = any>(sql: string, options?: DrizzleQueryOptions): Promise<T[]>;
|
|
22
|
-
withTransaction<T>(fn: (tx:
|
|
22
|
+
withTransaction<T>(fn: (tx: any) => Promise<T>): Promise<T>;
|
|
23
23
|
private buildDrizzleWhere;
|
|
24
24
|
private buildRawWhereClause;
|
|
25
25
|
private executeRawQuery;
|
|
@@ -40,5 +40,5 @@ export declare abstract class DrizzleSqlConnector {
|
|
|
40
40
|
abstract update(entity: string, filter: Record<string, any>, data: Record<string, any>, options?: DrizzleUpdateOptions): Promise<number>;
|
|
41
41
|
abstract delete(entity: string, filter: Record<string, any>, options?: DrizzleDeleteOptions): Promise<number>;
|
|
42
42
|
abstract query<T = any>(sql: string, options?: DrizzleQueryOptions): Promise<T[]>;
|
|
43
|
-
abstract withTransaction<T>(fn: (tx:
|
|
43
|
+
abstract withTransaction<T>(fn: (tx: any) => Promise<T>): Promise<T>;
|
|
44
44
|
}
|