UNPKG

@tsrt/typeorm-transactions

Version:
21 lines (20 loc) 1.39 kB
/// <reference types="node" /> import { Connection, EntityManager } from 'typeorm'; import { ColumnMetadataArgs } from 'typeorm/metadata-args/ColumnMetadataArgs'; import { EventEmitter } from 'events'; import { Namespace } from 'cls-hooked'; export declare type AnyFunction<T = any> = (...args: any) => T; export declare type GenericObject<T = any> = { [x: string]: T; }; export declare function createTransactionsNamespace(): Namespace; export declare function getTransactionsNamespace(): Namespace; export declare function bindTransactionsNamespace(req: EventEmitter, res: EventEmitter, next: AnyFunction): void; export declare function execInTransactionsNamespace<R extends AnyFunction>(cb: R): Promise<ReturnType<R>>; export declare function setManagerIntoNs(connectionName: string, manager: EntityManager): EntityManager; export declare function getManagerFromNs(connectionName: string): EntityManager; export declare function removeManagerFromNs(connectionName: string): EntityManager; export declare function getConnection(connectionFactory: Connection | AnyFunction<Connection>, connectionNameFactory: string | AnyFunction<string>): Connection; export declare function insertIntoClass<C, T>(context: C, data: T): void; export declare function getEntityColumns(target: Function): ColumnMetadataArgs[]; export declare function insertEntityProperties<C, T>(context: C, data: T): void;