Back

[SOLVED] Where do we add request for mass delete?

  • 0
  • Web
Camo
11 Jun, 2023, 18:15
TypeScript
WHERE column_name IN (value 1, value 2, value 3, etc...);```  is missing from web.sdk, we have to make several requests, which takes a ton of time if we want to delete .e.g 10k items.
TL;DR
The user is asking where to add a request for mass delete on GitHub. The solution is to create a feature request. The user also provides a code snippet for deleting documents one at a time, but it is slow for a large number of entries. There is a suggestion to optimize the deletion process by using an appwrite function and concurrently processing batches. The user also mentions that the web.sdk is missing a functionality for deleting multiple items at once using a single request.
Drake
11 Jun, 2023, 18:18

Making multiple requests is the way to go at the moment. to optimize this, you can:

  1. Have an appwrite function execute the API call so that there's less latency for the delete API calls
  2. Concurrently process batches rather than executing them serially
Camo
11 Jun, 2023, 18:39

well that's exactly what I do already ```js if(!payload.remove || !Array.isArray(payload.remove)){ return res.json({"error": "no payload", "payload": payload}, 400) }

const { remove } = payload;

const batchSize = 10; const totalBatches = Math.ceil(remove.length / batchSize);

for (let i = 0; i < totalBatches; i++) { const start = i * batchSize; const end = start + batchSize; const batchIds = remove.slice(start, end);

TypeScript
const promises = batchIds.map((id) => {
  return database.deleteDocument('default', 'rss_articles', id)
});

await Promise.all(promises);

}``` But it deletes one document at the time, imagine if there is a lot of entries, it will be a lot slower. Anyway, Are there any plans to look in to this ?

Drake
11 Jun, 2023, 18:55

Feel free to create a feature request

Camo
11 Jun, 2023, 18:56

Where exactly can I do that?

Drake
11 Jun, 2023, 18:56

GitHub issues

Camo
11 Jun, 2023, 18:56

Ok, thank you very much

Camo
11 Jun, 2023, 18:57

[Solved] Where do we add request for mass delete?

Camo
11 Jun, 2023, 18:57

[SOLVED] Where do we add request for mass delete?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more