Files
docmost/apps/server/src/helpers/db.helper.ts
Philipinho 3d90fc01ad * fixes and cleanups
* db transactions
* add default space to workspace
2024-03-01 01:07:30 +00:00

18 lines
420 B
TypeScript

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