fix: optimize existing record lookup in database sync process
Deploy Application / deploy (push) Successful in 35s Details

This commit is contained in:
faisolavolut 2025-11-20 15:00:40 +07:00
parent 2425144d6c
commit b5d5b1c272
1 changed files with 4 additions and 5 deletions

View File

@ -142,12 +142,11 @@ async function processDatabaseSync(database: any) {
select: { id: true, c_invoice_id: true },
});
const existingMap = new Map(
existingRecords.map((record) => [record.c_invoice_id, record.id])
);
for (const op of ops) {
const existingId = existingMap.get(op.c_invoice_id);
const existData = existingRecords.find(
(record) => record.c_invoice_id === op.c_invoice_id
);
const existingId = existData ? existData.id : null;
if (existingId) {
transactions.push(
db.rv_openitem.update({