astro-loader-pocketbase 2.7.0 → 2.7.1-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-loader-pocketbase",
3
- "version": "2.7.0",
3
+ "version": "2.7.1-next.1",
4
4
  "description": "A content loader for Astro that uses the PocketBase API",
5
5
  "keywords": [
6
6
  "astro",
@@ -95,14 +95,16 @@ export async function cleanupEntries(
95
95
 
96
96
  let cleanedUp = 0;
97
97
 
98
- // Get all ids of the entries in the store
99
- const storedIds = context.store
100
- .values()
101
- .map((entry) => entry.data.id) as Array<string>;
102
- for (const id of storedIds) {
103
- // If the id is not in the entries set, remove the entry from the store
104
- if (!entries.has(id)) {
105
- context.store.delete(id);
98
+ // Create a mapping from PocketBase IDs to store keys for proper cleanup
99
+ const storedIds = new Map<string, string>(
100
+ context.store.values().map((entry) => [entry.data.id as string, entry.id])
101
+ );
102
+
103
+ // Check which PocketBase IDs are missing from the server response
104
+ for (const [pocketbaseId, storeKey] of storedIds.entries()) {
105
+ // If the PocketBase ID is not in the entries set, remove the entry from the store
106
+ if (!entries.has(pocketbaseId)) {
107
+ context.store.delete(storeKey);
106
108
  cleanedUp++;
107
109
  }
108
110
  }