Skip to content

Commit

Permalink
Remove Postgres database service getTransactionRunner (#2097)
Browse files Browse the repository at this point in the history
  • Loading branch information
PooyaRaki authored Nov 7, 2024
1 parent 40e72aa commit e43375b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ export const mockPostgresDatabaseService = {
return callback(mockEntityManager);
},
),
getTransactionRunner: jest.fn().mockReturnValue(mockEntityManager),
} as jest.MockedObjectDeep<PostgresDatabaseService>;
15 changes: 2 additions & 13 deletions src/datasources/db/v2/postgres-database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {

@Injectable()
export class PostgresDatabaseService {
private transactionManager?: EntityManager = undefined;

public constructor(
@Inject(LoggingService) private readonly loggingService: ILoggingService,
@InjectDataSource()
Expand Down Expand Up @@ -88,18 +86,9 @@ export class PostgresDatabaseService {
callback: (transactionManager: EntityManager) => Promise<T>,
): Promise<T> {
return this.dataSource.transaction(
async (transactionalEntityManager): Promise<T> => {
this.transactionManager = transactionalEntityManager;
return await callback(this.transactionManager);
async (transactionalEntityManager: EntityManager): Promise<T> => {
return await callback(transactionalEntityManager);
},
);
}

public getTransactionRunner(): EntityManager {
if (!this.transactionManager) {
throw new Error('Query runner is not initialized...');
}

return this.transactionManager;
}
}

0 comments on commit e43375b

Please sign in to comment.