fix(pb): patch the repairs collection when a field is corrected, not only when one is added
This commit is contained in:
parent
f1073280ca
commit
1df399666d
1 changed files with 6 additions and 2 deletions
|
|
@ -169,10 +169,14 @@ async function main() {
|
|||
console.log("[repairs-fields] orders.repair already exists — skipping.");
|
||||
}
|
||||
|
||||
if (nextRepairsFields.length !== repairsFields.length) {
|
||||
// Patch when the array DIFFERS, not only when it grew — a
|
||||
// corrected field (e.g. clearing a length cap) keeps the same length.
|
||||
const changed = (a: PbField[], b: PbField[]) =>
|
||||
JSON.stringify(a) !== JSON.stringify(b);
|
||||
if (changed(repairsFields, nextRepairsFields)) {
|
||||
await pb.collections.update(repairs.id, { fields: nextRepairsFields });
|
||||
}
|
||||
if (nextOrdersFields.length !== ordersFields.length) {
|
||||
if (changed(ordersFields, nextOrdersFields)) {
|
||||
await pb.collections.update(orders.id, { fields: nextOrdersFields });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue