Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Add bulk delete methods

Smaug673965d9ea549bb3
diff --git a/frontend/app/stores/nodes.store.ts b/frontend/app/stores/nodes.store.ts
index f5bf87fd..fdddcd2f 100644
--- a/frontend/app/stores/nodes.store.ts
+++ b/frontend/app/stores/nodes.store.ts
@@ -329,6 +329,33 @@ export const useNodesStore = defineStore('nodes', {
allChildrens.forEach(childId => this.nodes.delete(childId));
} else throw request.message;
},
+
+ // Loop through ids and delete them one by one
+ // Only update the store after all deletions are successful
+ // Return the list of deleted ids and failed ids
+ async bulkDelete(ids: string[]) {
+ const deletedIds: string[] = [];
+ const failedIds: { id: string; message: string }[] = [];
+ for (const id of ids) {
+ try {
+ const request = await makeRequest(`nodes/${id}`, 'DELETE', {});
+ if (request.status === 'success') {
+ deletedIds.push(id);
+ } else {
+ failedIds.push({ id, message: request.message || 'Unknown error' });
+ }
+ } catch (error) {
+ failedIds.push({ id, message: (error as Error).message });
+ }
+ }
+ // Update store
+ deletedIds.forEach(id => {
+ const allChildrens = this.getAllChildrensIds(id);
+ this.nodes.delete(id);
+ allChildrens.forEach(childId => this.nodes.delete(childId));
+ });
+ return { deletedIds, failedIds };
+ },
/**
* Performs a fulltext search on the server using MySQL FULLTEXT index
* This is optimized for searching in document content (body)
diff --git a/frontend/app/stores/resources.store.ts b/frontend/app/stores/resources.store.ts
index c36f4470..965b6904 100644
--- a/frontend/app/stores/resources.store.ts
+++ b/frontend/app/stores/resources.store.ts
@@ -35,6 +35,30 @@ export const useRessourcesStore = defineStore('ressources', {
if (request.status == 'success') return useNodesStore().nodes.delete(id); // Remove the node from the cache
else throw request.message;
},
+ // Loop through ids and delete them one by one
+ // Only update the store after all deletions are successful
+ // Return the list of deleted ids and failed ids
+ async bulkDelete(ids: string[]) {
+ const deletedIds: string[] = [];
+ const failedIds: { id: string; message: string }[] = [];
+ for (const id of ids) {
+ try {
+ const request = await makeRequest(`nodes/${id}`, 'DELETE', {});
+ if (request.status === 'success') {
+ deletedIds.push(id);
+ } else {
+ failedIds.push({ id, message: request.message || 'Unknown error' });
+ }
+ } catch (error) {
+ failedIds.push({ id, message: (error as Error).message });
+ }
+ }
+ // Update store
+ deletedIds.forEach(id => {
+ useNodesStore().nodes.delete(id);
+ });
+ return { deletedIds, failedIds };
+ },
clear() {
this.ressources = [];
this.isFetching = false;