Back
AppwriteException (AppwriteException: , ClientException: Connection reset by peer)
- 0
- Self Hosted
- Functions
- Databases
I am tring to update 3000 + database records the permissions not the data .
TypeScript
import 'dart:async';
import 'dart:io';
import 'package:dart_appwrite/dart_appwrite.dart';
import 'package:starter_template/const.dart';
import 'package:starter_template/models/post.dart';
import 'package:starter_template/post_service.dart';
// This is your Appwrite function
// It's executed each time we get a request
Future<dynamic> main() async {
// Why not try the Appwrite SDK?
//
final client = Client()
.setEndpoint(Platform.environment['ENDPOINT']!)
.setProject(Platform.environment['APPWRITE_FUNCTION_PROJECT_ID'])
.setKey(Platform.environment['APPWRITE_API_KEY']);
final databases = Databases(client);
final x = await PostService(database: databases).getAllPosts();
print(x.length);
List<Future> futures = [];
for (var i = 0; i < x.length; i++) {
final post = x[i];
final d = databases.updateDocument(
databaseId: databaseID,
collectionId: postCOL,
documentId: post.id!,
//data: post.toJson(),
permissions: [
Permission.delete(Role.user(post.authorId!)),
Permission.update(Role.user(post.authorId!))
],
);
futures.add(d);
}
await Future.wait(futures);
exit(0);
}
TL;DR
- Update database records permissions by using pagination and creating smaller batches.
- Use the correct syntax for functions in Dart, refer to the Appwrite documentation.
- Ensure that the `Platform.environment` variables are correctly set.
- Issue could be due to attempting to update all records at once, causing a Connection Reset error.- use pagination & a slight delay to update all these docs' permissions. A single shot for updating (via
Futures) could fail. Create smaller batches. - use the correct syntax for functions, see - https://appwrite.io/docs/products/functions/develop#entrypoint and select
Dart. - make sure the
Platform.environmentare correctly set.
Recommended threads
- GOT 500 error when going to the appwrite...
I gott 500 internal error screen and my API is timeout. please help to take a look. Traceback (most recent call last): File "D:\conda\envs\wrista\Lib\site-pa...
- Update from 1.8 to 1.8.1 failing
I have spent the past 2 hours trying to figure this out but I really dont know what to do. 1.8. was a fresh install because the upgrade from 1.7.4 was a total m...
- Realtime not working for some tables
Hi, I've got an issue where I can setup a realtime connection to listen to some tables, but some not all. I have two tables `history` and `users`. Both can be ...