Files
docmost/apps/server/src/helpers/db.helper.ts
T
Philipinho a821e37028 Refactoring
* Refactor workspace membership system
* Create setup endpoint
* Use Passport.js
* Several updates and fixes
2024-03-16 22:58:12 +00:00

18 lines
434 B
TypeScript

import { DataSource, EntityManager } from 'typeorm';
export async function transactionWrapper(
operation: (...args) => any,
datasource: DataSource,
entityManager: EntityManager,
): Promise<any> {
if (entityManager) {
return await operation(entityManager);
} else {
return await datasource.manager.transaction(
async (manager: EntityManager) => {
return await operation(manager);
},
);
}
}