#[SOLVED] Delete a document containing a relationship's attribute

1 messages · Page 1 of 1 (latest)

tropic spindle
#

I've got a collection called movie_guilelisted which allow to user to recommend to another user a movie. Inside each document we got a movieId, userId (the user target) and bywhich is the user who recommend the movie. The by attribut is a relationship attribut to my collection users. The problem rn is if im connected which the user target account, I cant delete the document because there is a relationship attribut which is linked to a different user than the one on which I am connected. So what can I do ?

untold tide
#

Hello @tropic spindle
Does your movie document look something like this?
``
{
movieId: 'unique_value',
userId: 'target_id',
by: 'referrer_id'
}

``

And you would like to delete this document as a target user?

Can you please share your collection permissions or document security if you have any?

tropic spindle
#

Firstly, ive try to add document security but not working because user can only set permission to him, not to another specific user

#

Permissions:

untold tide
#

can you please share the permissions in the related collection as well?

tropic spindle
#

for the usercollection

#

ive just made a relationship attribut to get the username of the user who recommend the movie without making a request to get something like this :

untold tide
#

Can you try adding delete permission in the users collection and then try out your use case? For now the users should have permission to all the related collections as well to perform any crud operation.
We have a fix pending for this bug, once this is merged it should be good
https://github.com/appwrite/appwrite/pull/5815

GitHub

What does this PR do?
Fixes #5404 Update of document with relations without permissions of relation collection
Test Plan
Added E2E test case
Related PRs and Issues

#5404

Checklist

Have you rea...

tropic spindle
untold tide
#

Great, let us know if you're able to delete once you try it out or if you have any more questions

untold tide
#

Great!

tropic spindle
untold tide
#

For a more secure way, you can create an appwrite function which should validate permissions before doing any sort of crud operation

#

[solved] Delete a document containing a relationship's attribute