Creating following/follower feature in a social app - Database structure and feature implementation
- 0
- Databases
- Apple

Hi! I’m working on a social media app. I’m planning on using Appwrite to sign-up users. I would like to implement a following/follower/friend feature; a friend would be someone you follow that also follows you.
What would be the ideal way to structure this in an Appwrite database?
Should the following/followers be: array attributes on a user document, in it's own collection, or another way?
Also, how best to get the friends from a user's followers/following?

I would create a collection called following or something with two attributes: the id of the follower and the id of the person that follower is following

Thanks so much. So to get the followers, following, and friends would it involve doing the following:
Following: get all documents for which the user is the follower.
Followers: get all documents for which the user is the followee (person that someone is following).
Friends: on the client side, get the uuids from following and followers then use a set operation (intersection) to get the friends.
Is there a better way to do this? In particular for getting the friends?

You can have another collection for friends that is auto populated based on the following collection by an Appwrite function that executed automatically when someone follows or unfollows
Recommended threads
- Collection Relationship Issue
I'm unable to create a new relationship attribute. I'm new to this but I cannot figure out why other collections are not showing up.
- github copilot for xcode MCP AppWrite
I am trying to connect github copilot for xcode to appwrite mcp server. I keep getting a • MCP error -32000: Connection closed. I tried to verify my info, so...
- What's the recommended way to backup App...
I have two scripts I used before for backing up and restoring the database/volumes back when I moved my selfhosted instance from GCP to a home server. This was ...
