use await Promise.all in uploadedFile Product
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 6s

This commit is contained in:
Kanjana 2025-04-18 16:23:02 +07:00
parent 05d16f22de
commit e42b772dcf

View file

@ -518,8 +518,9 @@ export class ProductController extends Controller {
async (tx) => { async (tx) => {
const branch = productGroup.registeredBranch; const branch = productGroup.registeredBranch;
const company = (branch.headOffice || branch).code; const company = (branch.headOffice || branch).code;
console.log(branch, company);
for (const item of data) { await Promise.all(
data.map(async (item) => {
const dataDuplicate = productSameName.some( const dataDuplicate = productSameName.some(
(v) => v.code.slice(0, -3) === item.code.toUpperCase() && v.name === item.name, (v) => v.code.slice(0, -3) === item.code.toUpperCase() && v.name === item.name,
); );
@ -544,8 +545,8 @@ export class ProductController extends Controller {
productGroupId: productGroupId, productGroupId: productGroupId,
}); });
} }
} }),
console.log("dataProduct", dataProduct); );
return await prisma.product.createManyAndReturn({ return await prisma.product.createManyAndReturn({
data: dataProduct, data: dataProduct,