From 39a8bdfea669ae8a6edd263f1662330665ffde49 Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 20 May 2024 15:28:05 +0100 Subject: [PATCH] MapMembershipDestroy to top of deletions in updateMap function (#59) --- src/queries/map.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/queries/map.ts b/src/queries/map.ts index 0a3ee7c..af2f077 100644 --- a/src/queries/map.ts +++ b/src/queries/map.ts @@ -356,6 +356,10 @@ export const updateMap: MapUpdateFunction = async (mapId, name, data) => { } } + await MapMembership.destroy({ + where: { map_id: mapId }, + }); + if (markerIds.length) { console.log( `Removing ${markerIds.length} markers from DB for map ${mapId}` @@ -381,9 +385,6 @@ export const updateMap: MapUpdateFunction = async (mapId, name, data) => { }); } - await MapMembership.destroy({ - where: { map_id: mapId }, - }); console.log( `Adding ${mapData.markers.markers.length} markers to DB for map ${mapId}`