I want to create a relationship in my "Users" collection that'll point to it's own self. Tho I'm not building a social media app, but you can think of it as the friends list of a user in a social media network. So each user doc will need a relationship named "friends" to its own collection ("Users" in this case), cuz each "friend" is also a user. When I try doing it from the console, I can't find the "Users" collection under the "Related Collection" search box.
I don't know if I was clear enough... Let me know if you want more details
Ya...you can't at the moment. You can either create a friendship collection and then have relationship attributes to the user collection.
wouldn't it make it harder to manage? and what will the friendship collection contain?
I don't think so. I also usually avoid arrays because Appwrite doesn't support array operations
what the friendship collection should contain?
A two way many to one. This would allow you to see all the friends a user has from the user collection. Then, a one way many to one. Actually...this works more for a follower following scenario 🤔
do you mean, that whoever is added as a friend to anyone, should be added to the "friends" collection with a two-way many-to-one relationship with "Users"?
Yes, but there should be two attributes.
Maybe two documents should be added for each triend
about attributes, we need to store all the necessary info of the friend along with the relationship attribute. is there any more important attribute in your mind?
Maybe two documents should be added for each triend why two documents?
So that you can make 1 query to get all the friends of a user
if we do two-way many-to-many, then can't we just get all the friends of a user directly from the user doc? only need to get the corresponding user document and read the "friends" attribute?
sure i guess.
[SOLVED] How to create relationship within the same collection?
Recommended threads
- RowList: The value of total is coming as...
RowList: The value of total is coming as a String, so it throws an error because it’s not parsed into an int. Error: TypeError: \"37\": type 'String' is not a ...
- Appwrite console is too heavy
The Appwrite console is too heavy And all of my services broken Any support , please
- Usage of the new Client() and dealing wi...
Hey guys, just a quick one - we had some web traffic the other day and it ended up bombing out - To put in perspective of how the app works, we have a Nuxt Ap...