mirror of
https://github.com/docmost/docmost.git
synced 2026-07-15 04:26:48 +10:00
a821e37028
* Refactor workspace membership system * Create setup endpoint * Use Passport.js * Several updates and fixes
18 lines
434 B
TypeScript
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);
|
|
},
|
|
);
|
|
}
|
|
}
|