1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

refactor: rename rollback to more explicit rollbackTransaction (#7723)

This commit is contained in:
Mateusz Kwasniewski 2024-08-01 13:49:49 +02:00 committed by GitHub
parent d1e70eefbe
commit bbefff5d5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -41,8 +41,8 @@ export type WithTransactional<S> = S & {
transactional: <R>(fn: (service: S) => R) => Promise<R>;
};
export type WithRollback<S> = S & {
rollback: <R>(fn: (service: S) => R) => Promise<R>;
export type WithRollbackTransaction<S> = S & {
rollbackTransaction: <R>(fn: (service: S) => R) => Promise<R>;
};
/**
@ -86,13 +86,13 @@ export function withTransactional<S>(
return service;
}
export function withRollback<S>(
export function withRollbackTransaction<S>(
serviceFactory: (db: Knex) => S,
db: Knex,
): WithRollback<S> {
const service = serviceFactory(db) as WithRollback<S>;
): WithRollbackTransaction<S> {
const service = serviceFactory(db) as WithRollbackTransaction<S>;
service.rollback = async <R>(fn: (service: S) => R) => {
service.rollbackTransaction = async <R>(fn: (service: S) => R) => {
const trx = await db.transaction();
try {
const transactionService = serviceFactory(trx);