Back

Relationships between users and collections?

  • 0
  • Databases
  • Users
lemonjoe
29 Jun, 2023, 09:59

In the docs, there is a reference, that you can link users to documents in a relationship. But how can I do this? I don't see an option to create such a relationship in both user and document-collection.

I need to make sure, that documents will be deleted, if their creator-users will be deleted sometimes.

TL;DR
Users are wondering if they need to create a separate users collection in addition to the Auth collection. One user suggests setting documentId = userId and setting permission. Another user mentions that linking a user to a specific document in a collection is not possible. Someone suggests using the relationships feature and setting "cascade" to true. The user is unsure how to create such a relationship. They also want to ensure that documents are deleted if their creator users are deleted.
Bouahaza
29 Jun, 2023, 10:51

Where do you read that ?

Ananya
29 Jun, 2023, 10:54

Hey I am not sure but maybe you an use the relationships feature to establish a relationship between your collection and the users collection where you can set "cascade" to true. You can read more here: https://appwrite.io/docs/databases-relationships

Ananya
29 Jun, 2023, 10:54

Hope it helps 🙂

Bouahaza
29 Jun, 2023, 10:56

Relationship don't works with Auth users

loup
29 Jun, 2023, 12:12

ohh very usefull

loup
29 Jun, 2023, 12:14

We cant link user to a specific document in a collection ? Like I have a collection for extra user data like "username", "bio", etc... its cant super usefull to link each document to user because right now I have to add in each document the userId

Bouahaza
29 Jun, 2023, 12:25

You can't with real relation. Common case is to set documentId = userId and set permission

loup
30 Jun, 2023, 07:31

yeah this is what I did

lemonjoe
30 Jun, 2023, 12:05

Exactly ths document irritated me. Does this mean, that I have to create a users collection besides of the Auth collection?

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