Skip to content

Commit

Permalink
Fix bulkUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasr8 committed Nov 9, 2023
1 parent b3f5df1 commit 4b47e6c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pages/Events/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ export async function syncRegforms(
const deleted = onlyExisting.map(r => ({key: r.id, changes: {deleted: 1 as IDBBoolean}}));
await db.regforms.bulkUpdate(deleted);
// regforms that we have both locally and in Indico, just update them
const commonData = common.map(([{id}, data]) => ({key: id, changes: data}));
const commonData = common.map(([{id}, {id: _id, ...data}]) => ({
key: id,
changes: {...data, eventId: event.id},
}));
await db.regforms.bulkUpdate(commonData);
});
} else {
Expand Down Expand Up @@ -158,7 +161,10 @@ export async function syncParticipants(
}));
await addParticipants(newData);
// participants that we have both locally and in Indico, just update them
const commonData = common.map(([{id}, data]) => ({key: id, changes: data}));
const commonData = common.map(([{id}, {id: _id, eventId, ...data}]) => ({
key: id,
changes: {...data, regformId: regform.id},
}));
await db.participants.bulkUpdate(commonData);
});
} else {
Expand Down

0 comments on commit 4b47e6c

Please sign in to comment.