Skip to content

Commit

Permalink
refactor: rename rollback to more explicit rollbackTransaction (#7723)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Aug 1, 2024
1 parent d1e70ee commit bbefff5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib/db/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};

/**
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bbefff5

Please sign in to comment.