fix: error constraints

fix: error constraints
This commit is contained in:
Methapon Metanipat 2024-11-25 15:19:06 +07:00
parent 990a4687fd
commit e29ee46a2a

View file

@ -412,11 +412,14 @@ export class ServiceController extends Controller {
order: wIdx + 1, order: wIdx + 1,
attributes: w.attributes, attributes: w.attributes,
productOnWork: { productOnWork: {
create: w.product.map((p, pIdx) => ({ createMany: {
productId: p.id, data: w.product.map((p, pIdx) => ({
installmentNo: p.installmentNo, productId: p.id,
order: pIdx + 1, installmentNo: p.installmentNo,
})), order: pIdx + 1,
})),
skipDuplicates: true,
},
}, },
}, },
update: { update: {
@ -424,6 +427,7 @@ export class ServiceController extends Controller {
order: wIdx + 1, order: wIdx + 1,
attributes: w.attributes, attributes: w.attributes,
productOnWork: { productOnWork: {
deleteMany: {},
create: w.product.map((p, pIdx) => ({ create: w.product.map((p, pIdx) => ({
productId: p.id, productId: p.id,
installmentNo: p.installmentNo, installmentNo: p.installmentNo,