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:
parent
d1e70eefbe
commit
bbefff5d5a
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user