refactor: update isolation level

This commit is contained in:
Methapon2001 2024-06-11 14:00:45 +07:00
parent 784c245557
commit 73265c8965
2 changed files with 46 additions and 40 deletions

View file

@ -63,7 +63,8 @@ export class ProductGroup extends Controller {
@Post() @Post()
async createProductGroup(@Request() req: RequestWithUser, @Body() body: ProductGroupCreate) { async createProductGroup(@Request() req: RequestWithUser, @Body() body: ProductGroupCreate) {
const record = await prisma.$transaction(async (tx) => { const record = await prisma.$transaction(
async (tx) => {
const last = await tx.runningNo.upsert({ const last = await tx.runningNo.upsert({
where: { where: {
key: `PRODGRP`, key: `PRODGRP`,
@ -83,7 +84,9 @@ export class ProductGroup extends Controller {
updateBy: req.user.name, updateBy: req.user.name,
}, },
}); });
}); },
{ isolationLevel: Prisma.TransactionIsolationLevel.Serializable },
);
this.setStatus(HttpStatus.CREATED); this.setStatus(HttpStatus.CREATED);

View file

@ -77,7 +77,8 @@ export class ProductType extends Controller {
); );
} }
const record = await prisma.$transaction(async (tx) => { const record = await prisma.$transaction(
async (tx) => {
const last = await tx.runningNo.upsert({ const last = await tx.runningNo.upsert({
where: { where: {
key: `PRODTYP_T${productGroup.code}`, key: `PRODTYP_T${productGroup.code}`,
@ -97,7 +98,9 @@ export class ProductType extends Controller {
updateBy: req.user.name, updateBy: req.user.name,
}, },
}); });
}); },
{ isolationLevel: Prisma.TransactionIsolationLevel.Serializable },
);
this.setStatus(HttpStatus.CREATED); this.setStatus(HttpStatus.CREATED);