@przemyslawwalczak/nest-tx-typeorm
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha.10 • Public • Published

Usage

import { Injectable, Module } from '@nestjs/common';
import { InjectTransactionManager, TransactionManager } from '@leocode/nest-tx-core';
import {
  getEntityManagerFromTypeORMTransaction,
  TypeORMTransactionManagerModule
} from '@leocode/nest-tx-typeorm';

@Injectable()
class CatsService {
  constructor(
    @InjectTransactionManager() private readonly transactionManager: TransactionManager,
  ) {
  }

  public async save() {
    await this.transactionManager.withTransaction(async tx => {
      const manager = getEntityManagerFromTypeORMTransaction(tx);

      const qb = await manager
        .createQueryBuilder()
        .select('id')
        .from('cats')
        .getRawMany();
    });
  }
}


@Module({
  providers: [
    CatsService,
  ]
})
class CatsModule {}

@Module({
  imports: [
    TypeORMTransactionManagerModule.forRoot(),
    CatsModule,
  ],
})
class AppModule {}

/@przemyslawwalczak/nest-tx-typeorm/

    Package Sidebar

    Install

    npm i @przemyslawwalczak/nest-tx-typeorm

    Weekly Downloads

    0

    Version

    1.0.0-alpha.10

    License

    MIT

    Unpacked Size

    22 kB

    Total Files

    24

    Last publish

    Collaborators

    • pwalczak