Back

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

  • 1
  • Web
loup
24 Jul, 2023, 12:52

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 ?

TL;DR
User is having trouble deleting a document due to a relationship attribute. A suggested solution is to create an Appwrite function to validate permissions before performing any CRUD operations. The user confirms that the solution is working. There is also mention of a bug fix pending for the issue.
Prateek Banga
24 Jul, 2023, 13:04

Hello @loup 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?

loup
24 Jul, 2023, 13:14
loup
24 Jul, 2023, 13:14

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

loup
24 Jul, 2023, 13:15

Permissions:

Prateek Banga
24 Jul, 2023, 13:19

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

loup
24 Jul, 2023, 13:24

for the usercollection

loup
24 Jul, 2023, 13:25

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 :

Prateek Banga
24 Jul, 2023, 13:38

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

loup
24 Jul, 2023, 13:51

okay thx im gonna add the delete permission

Prateek Banga
24 Jul, 2023, 13:52

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

loup
24 Jul, 2023, 13:54

its working rn !

Prateek Banga
24 Jul, 2023, 13:54

Great!

loup
24 Jul, 2023, 13:56

Thx !

Prateek Banga
24 Jul, 2023, 14:01

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

Prateek Banga
24 Jul, 2023, 14:03

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

Prateek Banga
24 Jul, 2023, 14:03

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

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more