#Write permission doesn't work with document security on
16 messages · Page 1 of 1 (latest)
Write permission doesn't work with document security on
Update: actually this seems not be a visual bug. I won't be able to perform either update or delete with write permission on.
something is wrong there...it shouldn't have "write"
how did you grant "write"?
byPermission.write(). It's available in the Permission class and also stated in the official documentation
by the way...granting write permission in collection level works
Yes, but it should get added into the database as create, update, and delete
ikr, but it doesn't
i can't seem to reproduce your problem. What SDK and what version are you using?
Here's my payload:
and the result:
node.js sdk 12.0 and appwrite 1.5.7
Node sdk in the browser?
Also, what exactly is your code?
Sorry I didn't make it clear, it's on node.js environment. The package I use is node-appwrite 12.0.0. I had an initialization script to set up default users, workshopOffer is nested in user->workshop->workshopOffer. The code is as below. By the way I have already changed Permission.write() to a combination of Permission.update() and Permission.delete(). I am not sure if this bug persists cuz it didn't happen at later times.
`
let anyReadPermissions = [Permission.read(Role.any())]; // all users can read this collection
// permission.write doesn't work on document level, grant one by one
let userWritePermissions = (userID) => {
return [
Permission.write(Role.user(userID))
]
}
databases.createDocument(
...collectionUser,
"2",
{
userID: "2",
name: "xxx",
type: "organization",
// create document in inventory
userInventory: {
grain: 100,
$permissions: anyReadPermissions,
},
// create document in money
userMoney: {
gold: 1000,
coin: 10000,
$permissions: anyReadPermissions,
},
company: {
name: "Han State-owned",
$permissions: [Permission.update(Role.user("2"))],
},
workshop: [
{
name: "xxx",
type: "grain",
level: 5,
city: "1",
workshopOffer: [{ ecoSkill: 1, currency: "xxx", salary: 1, $permissions: userWritePermissions("2") }],
},
]
},
anyReadPermissions
),`