UNPKG

@nodeboot/starter-persistence

Version:

Nodeboot starter package for persistence. Supports data access layer auto-configuration providing features like database initialization, consistency check, entity mapping, repository pattern, transactions, paging, migrations, persistence listeners, persis

39 lines 1.95 kB
import { WrapInTransactionOptions } from "typeorm-transactional"; import { MongoRepository } from "typeorm"; /** * Registers a callback to be executed when the current transaction is successfully committed. * * @param cb - The callback function to execute on transaction commit. */ export declare const runOnTransactionCommit: (cb: () => void) => void; /** * Registers a callback to be executed when the current transaction is rolled back. * * @param cb - The callback function that receives the error that caused the rollback. */ export declare const runOnTransactionRollback: (cb: (e: Error) => void) => void; /** * Registers a callback to be executed when the current transaction is either committed or rolled back. * * @param cb - The callback function that receives an optional error (if the transaction was rolled back). */ export declare const runOnTransactionComplete: (cb: (e: Error | undefined) => void) => void; /** * Executes a given function within a transaction. * * @template F - The function type to be executed inside the transaction. * @param fn - The function to be executed within the transaction. * @param options - Optional transaction options (e.g., isolation level, propagation). * @returns The result of the function execution within the transaction. */ export declare const runInTransaction: <F extends (this: unknown) => ReturnType<F>>(fn: F, options?: WrapInTransactionOptions) => ReturnType<F>; /** * Retrieves the MongoDB client associated with a given TypeORM MongoRepository instance. * * @template R - A repository extending MongoRepository. * @param repoInstance - An instance of a MongoRepository. * @returns The MongoClient instance used by the repository. * @throws Error if the function is called outside of a MongoRepository. */ export declare function useMongoClient<R extends MongoRepository<any>>(repoInstance: R): import("typeorm").MongoClient; //# sourceMappingURL=hooks.d.ts.map