I solved it by converting object into array, Thank you for helping me
I'd really like to figure out how it happened so that we could prevent it from happening again, but I can't reproduce the problem
Did you here updated the document or creating it?
Both
What were the permissions on the created document before updating?
It was normal string[], everything is ok till i update the document, then it breaks.....it is weird that it happends to me every single time and for you it works properly
Exact value would be helpful so I could try and reproduce
Before i update the document, incoming permissions look like this: permissions: [ 'read("any")', 'read("user:642090ce0b988edac790")', 'read("user:642090ce0b988edac790")', 'write("user:642090ce0b988edac790")', 'update("user:642090ce0b988edac790")', 'delete("user:642090ce0b988edac790")' ]
then when i getDocument, it comes like this:
"$permissions": { "0": "read(any)", "1": "read(user:642090ce0b988edac790)", "3": "update(user:642090ce0b988edac790)", "4": "delete(user:642090ce0b988edac790)" },
No I meant what was the permissions on the document before you updated it
Yes, sorry for misunderstanding, these are permissions before i update the document -$permissions: [ 'read("any")', 'read("user:642090ce0b988edac790")', 'update("user:642090ce0b988edac790")', 'delete("user:642090ce0b988edac790")' ]
Then, when i update that document and when i load that document, i get this: "$permissions": { "0": "read("any")", "1": "read("user:642090ce0b988edac790")", "3": "update("user:642090ce0b988edac790")", "4": "delete("user:642090ce0b988edac790")" },
After updating i cant event open document in console (cloud.appwrite.io)
even*
i still can't reproduce. this is my code:
const initialPermissions = [
'read("any")',
'read("user:642090ce0b988edac790")',
'update("user:642090ce0b988edac790")',
'delete("user:642090ce0b988edac790")'
];
console.log(initialPermissions);
const created = await databases.createDocument(
'default',
'test',
'permission',
{
b: true
},
initialPermissions
);
console.log(created);
const updatedPermissions = [
'read("any")',
'read("user:642090ce0b988edac790")',
'read("user:642090ce0b988edac790")',
'write("user:642090ce0b988edac790")',
'update("user:642090ce0b988edac790")',
'delete("user:642090ce0b988edac790")'
]
const updated = await databases.updateDocument(
'default',
'test',
created.$id,
{
b: false,
},
updatedPermissions
);
console.log(updated);
this is the output:
[
'read("any")',
'read("user:642090ce0b988edac790")',
'update("user:642090ce0b988edac790")',
'delete("user:642090ce0b988edac790")'
]
{
b: true,
'$id': 'permission',
'$permissions': [
'read("any")',
'read("user:642090ce0b988edac790")',
'update("user:642090ce0b988edac790")',
'delete("user:642090ce0b988edac790")'
],
'$createdAt': '2023-06-05T01:09:10.059+00:00',
'$updatedAt': '2023-06-05T01:09:10.059+00:00',
s: 'default value',
i: null,
'$collectionId': 'test',
'$databaseId': 'default'
}
{
b: false,
s: 'default value',
i: null,
'$id': 'permission',
'$createdAt': '2023-06-05T01:09:10.059+00:00',
'$updatedAt': '2023-06-05T01:09:10.617+00:00',
'$permissions': [
'read("any")',
'read("user:642090ce0b988edac790")',
'read("user:642090ce0b988edac790")',
'update("user:642090ce0b988edac790")',
'delete("user:642090ce0b988edac790")',
'update("user:642090ce0b988edac790")',
'delete("user:642090ce0b988edac790")'
],
'$collectionId': 'test',
'$databaseId': 'default'
}
Are you using node-appwrite version 9.0.0?
Yep
wait a minute! the result of updateDocument() for me was right, but then if i getDocument() again, it shows the problem
here's the created issue: https://github.com/appwrite/appwrite/issues/5661
What do you suggest me to do now? I cant continue programming
i suggest not passing duplicate data (the extra read and the write permissions)
Oh, ok thank you for helping
Recommended threads
- Deleted my account, trying to signup aga...
https://cloud.appwrite.io/console/login?error=%7B%22message%22%3A%22This+email+address+must+already+be+in+its+canonical+form.+Please+remove+aliases%2C+tags%2C+o...
- TOO_MANY_REDIRECTS after temporarily ena...
I am losing my mind over this, I enabled this setting because I was having issues with sites not making links with https. I enabled it, ran into issues, so I di...
- Unable to create Sites or Functions with...
Heya, I was looking at the appwrite documentation for Sites API with the server api: https://appwrite.io/docs/references/cloud/server-nodejs/sites I canβt fin...