Hello, I am trying to read docs from locally hosted appwrite. DocumentList throws no error if there is no document, and when i add a doc the following exception throws
TypeScript
#0 new Document.fromMap (package:appwrite/src/models/document.dart:41:42)
#1 new DocumentList.fromMap.<anonymous closure> (package:appwrite/src/models/document_list.dart:20:68)
#2 MappedListIterable.elementAt (dart:_internal/iterable.dart:435:31)
#3 ListIterator.moveNext (dart:_internal/iterable.dart:364:26)
#4 new List.from (dart:core-patch/array_patch.dart:29:17)
#5 new DocumentList.fromMap (package:appwrite/src/models/document_list.dart:20:11)
#6 Databases.listDocuments (package:appwrite/services/databases.dart:33:32)
<asynchronous suspension>
#7 main (package:pharmalytics/main.dart:15:13)
<asynchronous suspension>
TL;DR
Issue: When attempting to read documents from a locally hosted Appwrite, DocumentList throws an exception due to a mismatch in data types for permissions.
Solution: Update the code snippet to correctly handle incoming permission data as a List of dynamic types:
```
$permissions: (List.from(map['\$permissions']) ?? <String>[]),
```
GitHub open issue for reference: https://github.com/appwrite/appwrite/issues/9116TypeScript
final db = client.databases;
final k = await db.listDocuments(databaseId: '6765d0e500231e6fff09', collectionId: '6765d1160000b344e358');
print(k.documents); // throws```
looks like the following from appwrite sdk is the issue
TypeScript
return Document(
$id: map['\$id'].toString(),
$collectionId: map['\$collectionId'].toString(),
$databaseId: map['\$databaseId'].toString(),
$createdAt: map['\$createdAt'].toString(),
$updatedAt: map['\$updatedAt'].toString(),
$permissions: map['\$permissions'] ?? [],
data: map,
);
}```
something like this fixed the issue because the incoming permision data from the map is actually of List dynamic
``` $permissions: (List.from(map['\$permissions']) ?? <String>[]),```
Recommended threads
- MongoDb Database Breaks integer[] & bigi...
I've got a table with the below column created. When I try to insert the value `[-3408048000]` into it, the dart sdk cloud function call is successful (no error...
- 1.9.6 Console handles all array columns ...
When creating or updating a row in the appwrite 1.9.6 web console, the form treats all list columns as a type string. Even if the column is a list of booleans, ...
- Temporary $permissions hickup?
Hello, today at ~13:50 (CEST/UTC+2) our customers reported they couldn't see any data in our application. We checked and indeed, the application was working, bu...