1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +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>; transactional: <R>(fn: (service: S) => R) => Promise<R>;
}; };
export type WithRollback<S> = S & { export type WithRollbackTransaction<S> = S & {
rollback: <R>(fn: (service: S) => R) => Promise<R>; rollbackTransaction: <R>(fn: (service: S) => R) => Promise<R>;
}; };
/** /**
@ -86,13 +86,13 @@ export function withTransactional<S>(
return service; return service;
} }
export function withRollback<S>( export function withRollbackTransaction<S>(
serviceFactory: (db: Knex) => S, serviceFactory: (db: Knex) => S,
db: Knex, db: Knex,
): WithRollback<S> { ): WithRollbackTransaction<S> {
const service = serviceFactory(db) as WithRollback<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(); const trx = await db.transaction();
try { try {
const transactionService = serviceFactory(trx); const transactionService = serviceFactory(trx);