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
- Relationship data Not showing on update ...
Version : 1.9.0 OS/System : Windows10/Docker Database : MongoDB Clean Zero Installation The first thing I did in the testing process was create a category and...
- I lost my account, only thing i have is ...
So i had this project on appwrite for my web project called Islami zindagi, but i havent used it in a while, now i tried to login, but i could not remember the ...
- 403 The current user has been blocked.
Hello, I have a free plan; I've tried to access my project and I get the message "403 The current user has been blocked." I have database, sites, and auth in us...