1.0.0-alpha.10 • Published 3 years ago
@przemyslawwalczak/nest-tx-typeorm v1.0.0-alpha.10
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 {}
1.0.0-alpha.10
3 years ago
1.0.0-alpha.9
3 years ago
1.0.0-alpha.8
3 years ago
1.0.0-alpha.7
3 years ago
1.0.0-alpha.6
3 years ago
1.0.0-alpha.5
3 years ago