Skip to content

Commit

Permalink
Return value from the TypeOrm transaction callback (#2096)
Browse files Browse the repository at this point in the history
  • Loading branch information
PooyaRaki authored Nov 6, 2024
1 parent a1c7f31 commit cea811a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/datasources/db/v2/postgres-database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ export class PostgresDatabaseService {
return this.dataSource.getRepository<T>(entity);
}

public async transaction(
callback: (transactionManager: EntityManager) => Promise<void>,
): Promise<void> {
public async transaction<T>(
callback: (transactionManager: EntityManager) => Promise<T>,
): Promise<T> {
return this.dataSource.transaction(
async (transactionalEntityManager): Promise<void> => {
async (transactionalEntityManager): Promise<T> => {
this.transactionManager = transactionalEntityManager;
await callback(this.transactionManager);
return await callback(this.transactionManager);
},
);
}
Expand Down

0 comments on commit cea811a

Please sign in to comment.