Rank 1: Thread
How can I create a following system like on social sites? When 1 user can follow for another. I need to create subcollection, but I do not know how is it possible. I need to array with users id that follow for another user.
Votes
0
Replies
12
Participants
Unknown
Messages
13
Rank 1: Thread
How can I create a following system like on social sites? When 1 user can follow for another. I need to create subcollection, but I do not know how is it possible. I need to array with users id that follow for another user.
Moderator
Technically there are a lot of different ways you can do it, some use arrays, others use relationships, I personally would probably use a hybrid but here’s a guide that might help made pretty recently https://m.youtube.com/watch?v=8N-0Ef1oC1w
Moderator
That’s flutterflow but the logic is the same, I had a better one one sec
Moderator
Rank 1: Thread
but how can I add in appwrite that attribute into users collection? I didn't find any array or way to create subcollection with following users id
Rank 1: Thread
I've found only enum, but I can not to add the type as a user's id
Rank 1: Thread
also when I created the followers collection, I can not to add attributes like user and his follower, because follower is from users collection
Rank 1: Thread
I don't understand how to add a followers array with type of user's id into a user document
Rank 3: Container
Appwrite supports arrays just select the type (e.g. for user id you'd select String) and in the form that appears tick Array . Unlike Firebase that provides a NoSQL DB, appwrite uses a SQL DB thus the idea of a subcollection is simply another collection that is related to a different collection either by appwrite relationships (that uses foreign keys) or custom implementation (doing it manually)
Rank 3: Container
You're not supposed to add all the data about the user to the followers collection. Typically, it's enough just having the follower and the followed (for easy distinction let's use the term leader) ids. Example:
Following collection
leaderID | followerID
user1 ID | user2ID (user1 follows user2)
user3ID | user 8ID
user2 ID | user1ID (user2 follows user1 back; mutual following)
NB: This is a relationship based approach which is different from the array based approach
Rank 1: Thread
Oh, that so simple 😅 .
Rank 1: Thread
ty
Rank 1: Thread
Remember your indexes if you don’t want to have a very bad time as the data increases