fix: optimize existing record lookup in database sync process
Deploy Application / deploy (push) Successful in 35s
Details
Deploy Application / deploy (push) Successful in 35s
Details
This commit is contained in:
parent
2425144d6c
commit
b5d5b1c272
|
|
@ -142,12 +142,11 @@ async function processDatabaseSync(database: any) {
|
||||||
select: { id: true, c_invoice_id: true },
|
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) {
|
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) {
|
if (existingId) {
|
||||||
transactions.push(
|
transactions.push(
|
||||||
db.rv_openitem.update({
|
db.rv_openitem.update({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue