astro-loader-pocketbase 2.5.0-next.2 → 2.5.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
|
@@ -32,9 +32,21 @@ export async function cleanupEntries(
|
|
|
32
32
|
|
|
33
33
|
// Fetch all ids of the collection
|
|
34
34
|
do {
|
|
35
|
+
// Build search parameters
|
|
36
|
+
const searchParams = new URLSearchParams({
|
|
37
|
+
page: `${++page}`,
|
|
38
|
+
perPage: "1000",
|
|
39
|
+
fields: "id"
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (options.filter) {
|
|
43
|
+
// If a filter is set, add it to the search parameters
|
|
44
|
+
searchParams.set("filter", `(${options.filter})`);
|
|
45
|
+
}
|
|
46
|
+
|
|
35
47
|
// Fetch ids from the collection
|
|
36
48
|
const collectionRequest = await fetch(
|
|
37
|
-
`${collectionUrl}
|
|
49
|
+
`${collectionUrl}?${searchParams.toString()}`,
|
|
38
50
|
{
|
|
39
51
|
headers: collectionHeaders
|
|
40
52
|
}
|
|
@@ -47,14 +59,17 @@ export async function cleanupEntries(
|
|
|
47
59
|
context.logger.error(
|
|
48
60
|
`The collection is not accessible without superuser rights. Please provide superuser credentials in the config.`
|
|
49
61
|
);
|
|
50
|
-
|
|
62
|
+
} else {
|
|
63
|
+
const reason = await collectionRequest
|
|
64
|
+
.json()
|
|
65
|
+
.then((data) => data.message);
|
|
66
|
+
const errorMessage = `Fetching ids failed with status code ${collectionRequest.status}.\nReason: ${reason}`;
|
|
67
|
+
context.logger.error(errorMessage);
|
|
51
68
|
}
|
|
52
69
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const errorMessage = `Fetching ids failed with status code ${collectionRequest.status}.\nReason: ${reason}`;
|
|
57
|
-
context.logger.error(errorMessage);
|
|
70
|
+
// Remove all entries from the store
|
|
71
|
+
context.logger.info(`Removing all entries from the store.`);
|
|
72
|
+
context.store.clear();
|
|
58
73
|
return;
|
|
59
74
|
}
|
|
60
75
|
|