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
- Upgrading selfhost version?
It is okay to upgrade version to higher one, of my current version is 1.7.4 to 1.8.1. Is that safe to do cause my clients already have data on that? Also is a...
- Appwrite cloud DB server error 500
Getting this error
- appwrite indexes not working (?
i have this index: ``` "indexes": [ { "key": "single-user-per-event", "type": "unique", ...