Back

Relationships between same collection

  • 0
  • Databases
diaz
2 Jan, 2024, 00:43

hello , i have a collection named “clients” and i want theme to have relationship between each others , how can i achieve this ? Thanks

TL;DR
OP wants to create relationships between documents in the same collection named "clients". Another user suggests creating a separate collection called "Friends" to store the friend relationships. OP agrees and says it's more efficient than having one attribute for "friends".
ideclon
2 Jan, 2024, 00:55

When you create Attributes on your Collection, one of the type options is Relationship

diaz
2 Jan, 2024, 01:01

Thank you, but you cant do it with the same collection

ideclon
2 Jan, 2024, 01:01

That’s correct. Why would you want to?

diaz
2 Jan, 2024, 11:12

its an option i need to have on@my project, imagine users can have friends , how can you add the relationship of the same collection?

ideclon
2 Jan, 2024, 12:54

I see. I think the best way to do it is probably to have a separate Collection “Friends”, which would have a Document for each Friend relationship.

ideclon
2 Jan, 2024, 12:55

This is more efficient anyway than having one huge Attribute (a user could potentially have thousands of “friends”)

diaz
2 Jan, 2024, 17:57

Yea you are right i just didn’t explain it well, i tried it but it didnt work with one way relationship i tried with two ways relationships with new documents « friendship » and it did work , thank you @ideclon

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