is this will be worked as batch delete ? ```dart class FutureGroup<T> { final List<Completer<T>> _completers = []; final int maxConcurrent;
FutureGroup({this.maxConcurrent = 1});
Future<void> add(Future<T> future) async { if (_completers.length >= maxConcurrent) { await Future.any(_completers.map((c) => c.future)); }
final completer = Completer<T>();
_completers.add(completer);
future.whenComplete(() => _completers.remove(completer));
return completer.complete(await future);
}
Future<void> close() => Future.wait(_completers.map((c) => c.future)); }
Future<void> deleteDocumentsConcurrently(List<String> documentIds) async { final batchFutures = FutureGroup(maxConcurrent: 100);
for (final documentId in documentIds) { await batchFutures.add(database.deleteDocument( databaseId: "6439e7ae4abb3e14f2b1", collectionId: "64444e34a0ce20bc4ac8", documentId: documentId, )); }
await batchFutures.close(); print('All documents deleted'); }````
Where did you come up with this?
generated this code from chatgpt, it's working but getting rate limit error if its enable else its deleting all document .
I highly recommend you take the time to really understand how dart works and how to write the code yourself. You're going to continuously struggle if you don't take the time to learn.
As mentioned in the other thread, rate limits are expected when executing client-side. See https://appwrite.io/docs/rate-limits
where can i learn this.
Maybe you should find a course on dart or take time to write code yourself rather than asking someone else to give you code
Do that server-sided with a function as mentioned
Thanks for suggestion @D5 , if i use cloud function then have to pass long payload data as result it will give this error "Invalid data: Value must be a valid string and at least 1 chars and no longer than 8192 chars"
and same goes for creation of bunch of document creation that is why not using cloud function. hope you got my point.
You don't need to pass everything as payload, since you can get the data directly from the server instead from getting the data client-sided and then sending everything again to the server/function
is there is any documentation for getting data form server side.
You can do it as if you were making that client sided, but using a token to allow the function accessing everything
However, there's a specific server SDK: https://appwrite.io/docs/getting-started-for-server
ok this time got your point,
Functions don't have rate limits when modifying data, so, probably you will not face any problems related to that
but what about if we are creating bunch of doc, because in this case we are sending data to server.
Just curious, why do you need to create a bunch of docs instead of creating them one by one?
yes got it.
beause users wants to export all product data to appwrite database in just single.
or i can say want to upload list of product data more then 10k to database so that he don't have to upload every single produt one by one.
this is the usecase
I think a better approach could be managing a CSV file server-sided or making that gradually instead of everything at once. Note that if an user is making that, others will notice a slower app, so it's better a slow import/export without affecting others, that a fast transfer, while affecting everyone. Maybe @Steven has a better approach?
Also note that if you allow unlimited import/export transfer rate, someone could intentionally DoS you app easily
noted.
Thanks @D5
tried this as you suggested. but deleting one by one from server side using function is crashing the sever.
Recommended threads
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...