mirror of
https://github.com/seerr-team/seerr.git
synced 2026-10-12 11:29:55 +00:00
13 lines
542 B
TypeScript
13 lines
542 B
TypeScript
import type { EntityManager } from 'typeorm';
|
|
|
|
// sqlite savepoints race on shared transactionDepth as it shares one query runner process-wide
|
|
// so nesting collides on savepoint counter, see https://github.com/typeorm/typeorm/issues/10209
|
|
// and later reverted by https://github.com/typeorm/typeorm/issues/11260
|
|
export const withNestedTransaction = <T>(
|
|
manager: EntityManager,
|
|
run: (manager: EntityManager) => Promise<T>
|
|
): Promise<T> =>
|
|
manager.connection.options.type === 'sqlite'
|
|
? run(manager)
|
|
: manager.transaction(run);
|