Typeorm Transactional Cls Hooked

screenshot of Typeorm Transactional Cls Hooked
nestjs

A Transactional Method Decorator for typeorm that uses cls-hooked to handle and propagate transactions between different repositories and service methods. Inpired by Spring Trasnactional Annotation and Sequelize CLS

Overview

The typeorm-transactional-cls-hooked is a powerful library that introduces a transactional method decorator for TypeORM, reminiscent of the renowned Spring Transactional Annotation. It harnesses the capabilities of cls-hooked to manage and seamlessly propagate transactions across various repositories and service methods, enhancing the consistency and reliability of database operations. This library is particularly relevant for developers who are looking to integrate robust transaction management into their applications while keeping the benefits of TypeORM's functionality.

With its intuitive API and clear design, it simplifies the handling of complex transactional processes, making it suitable for applications that require intricate data operations. By extending the base repository classes and providing decorators for service methods, it ensures developers can maintain full control over their transaction lifecycles without introducing significant overhead.

Features

  • Transactional Decorator: Use the @Transactional() decorator to easily mark service methods that require transaction management, making it clear and concise.

  • Custom Repository Support: Extend either BaseRepository or BaseTreeRepository to ensure that the manager property is correctly set for all your TypeORM repositories.

  • Dynamic Connection Names: Specify a dynamic connection name for the transactional methods, offering flexibility in multi-tenant applications.

  • Transaction Propagation Options: Configure how transactions should behave with various propagation options, including MANDATORY, NESTED, NEVER, NOT_SUPPORTED, and REQUIRED.

  • Isolation Level Configurability: Adjust the isolation level for transactions to meet specific data integrity needs, leveraging your database driver's defaults or custom settings.

  • Patching Support: Easily patch existing TypeORM repositories without having to modify your codebase, allowing for a smoother integration experience.

  • Initialization Requirements: Clear guidelines on initializing the library ensure that developers can set up the transactional context correctly before their application runs.

  • Inspiration from Established Patterns: The design of the library is influenced by established frameworks like Spring and Sequelize, making it familiar for developers transitioning between technologies.

nestjs
Nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.