You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Injectable()exportclassSupplierService{constructor(
@InjectRepository(Supplier)privatereadonlysupplierRepository: Repository<Supplier>,
@Inject(forwardRef(()=>MaterialService))privatereadonlymaterialService: MaterialService,){}asynccreate(createSupplierDto: CreateSupplierDto){awaitthis.checkNoSameName(createSupplierDto);constnewSupplier=this.supplierRepository.create(createSupplierDto);returnawaitthis.supplierRepository.save(newSupplier);}asyncfindAll(){returnawaitthis.supplierRepository.find();}asyncfindOne(id: number){returnawaitthis.supplierRepository.findOneBy({ id });}asyncfindOneByName(name: string){returnawaitthis.supplierRepository.findOneBy({ name });}asyncupdate(id: number,updateSupplierDto: UpdateSupplierDto){awaitthis.checkNoSameName(updateSupplierDto);constsupplier=awaitthis.findOne(id);if(!supplier){thrownewNotFoundException('Supplier not found!');}returnthis.supplierRepository.save({ ...supplier, ...updateSupplierDto});}asyncremove(id: number){constsupplier=awaitthis.findOne(id);if(!supplier){thrownewNotFoundException('Supplier not found!');}// since many materials can't survive without supplier// check before deleting this supplier that there's no material belonging to itconsttaggedMaterials=awaitthis.materialService.findTaggedSupplier(id);if(taggedMaterials.length>0){thrownewBadRequestException(ERROR_MESSAGE_FORMATS.SUPPLIER.TAGGED_MATERIALS(taggedMaterials.length),);}returnthis.supplierRepository.remove(supplier);}asynccheckNoSameName(dto: UpdateSupplierDto){if(!dto||!dto.name)return;constsameNameSupplier=awaitthis.findOneByName(dto.name);if(sameNameSupplier){thrownewBadRequestException(ERROR_MESSAGE_FORMATS.SUPPLIER.SAME_NAME(sameNameSupplier.id),);}}}
I've noticed that the examples all dictate service-level transactions. But may I ask if controller level transactions are okay?
Note: I have GET endpoints use the propagation level of SUPPORTS because for some reason when I have my FE do concurrent GET requests it'll throw a SQLITE_ERROR: cannot start a transaction within a transaction
tldr
Are controller level transactions are okay?
GET endpoints with transactions throw SQLITE_ERROR: cannot start a transaction within a transaction when hit concurrently, what's the proper way to fix this case? I was under the impression that REQUIRES_NEW (default) supports current transaction instead of starting new when there's one
The text was updated successfully, but these errors were encountered:
Currently I have this on my NestJS application on the controller level
Controller level:
Service Level:
Datasource
I've noticed that the examples all dictate service-level transactions. But may I ask if controller level transactions are okay?
Note: I have GET endpoints use the propagation level of SUPPORTS because for some reason when I have my FE do concurrent GET requests it'll throw a
SQLITE_ERROR: cannot start a transaction within a transaction
tldr
SQLITE_ERROR: cannot start a transaction within a transaction
when hit concurrently, what's the proper way to fix this case? I was under the impression that REQUIRES_NEW (default) supports current transaction instead of starting new when there's oneThe text was updated successfully, but these errors were encountered: