import { InjectRepository } from '@nestjs/typeorm' ; import { EntityManager , Repository , Transaction , TransactionManager } from 'typeorm' ; import { Purse } from './model/purse.model' ; import { Injectable } from '@nestjs/common' ; import { TransactionFor } from 'nest-transact' ; import { ModuleRef } from '@nestjs/core' ; @ Injectable ( ) export class AppServiceV2 extends TransactionFor < AppServiceV2 > { constructor ( @ InjectRepository ( Purse ) private readonly purseRepository , moduleRef ) { super ( moduleRef ) ; } async savePurse ( purse ) { await this . purseRepository . save ( purse ) ; } @ Transaction ( ) async savePurseInTransaction ( purse , @ TransactionManager ( ) transactionManager = null ) { await transactionManager . save ( Purse , purse ) ; } async savePurseInTransactionV2 ( purse , transactionManager ) { await transactionManager . save ( Purse , purse ) ; } }