Hi there, I am writing a dart function for cloud which basically deletes a document owned by a user and removes read permissions of the users in all other documents in a specific scope. For testing I am creating a document like this:
// Create guestCommObjects for the event
removeGuestCommObject = await database.createDocument(
databaseId: databaseId,
collectionId: guestCommObjectCollectionId,
documentId: removeGuestCommObjectId,
data: {
'eventId': event!.$id,
'userId': removeGuestId,
'isRegisteredUser': true,
},
permissions: [
Permission.read(Role.user(ownerId)),
Permission.write(Role.user(ownerId)),
Permission.delete(Role.user(ownerId)),
Permission.read(Role.user(guestId1)),
Permission.read(Role.user(guestId2)),
Permission.read(Role.user(removeGuestId)),
Permission.update(Role.user(removeGuestId)),
],
);
So far so good, now when I am making this getDocument call:
guestCommObject = await database.getDocument(
databaseId: privateEventDatabaseId,
collectionId: guestCommObjectCollectionId,
documentId: payload['guestCommObjectId'],
);
It throws a _TypeError: '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>'
For me this looks like an error in the Document.fromMap() Error or I am putting these permissions wrong, but why doesnt it throw an exception during create?
would you please replace the Permission.write() with Permission.update()?
Yes, that did the trick. Or just deleting the Permission.delete() since Permission.write() is update and delete correct?
But I found it strange that I can create an document which is falsy
yes correct...I'm pretty sure this was fixed in a newer version of Appwrite
[SOLVED] _TypeError for getDocument with Permissions
Alright, thank you Steven! <:appwriteheart2:1073243188954935387>
Recommended threads
- Auth not working on expo react native
I'm trying to launch a development server with expo go and appwrite as a backend. On my windows pc, I've got a local docker instance of appwrite running as my b...
- Urgent help required - Could not resolve...
I upgraded my production environment to 1.8.0 but experienced issues with appwrite running out of worker threads. I downgraded back to 1.6.1 and restored the da...
- createMembership is not sending email wi...
Parameters should be correct. Account and Membership are successfully created. I have a next.js project with localhost origin allowed. I checked spam etc. i...