
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.

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

That’s flutterflow but the logic is the same, I had a better one one sec


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

I've found only enum, but I can not to add the type as a user's id

also when I created the followers collection, I can not to add attributes like user and his follower, because follower is from users collection

I don't understand how to add a followers array with type of user's id into a user document

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)

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

Oh, that so simple 😅 .

ty

Remember your indexes if you don’t want to have a very bad time as the data increases
Recommended threads
- Stuck in "deleting"
my parent element have relationship that doesnt exist and its stuck in "deleting", i cant delete it gives me error: Collection with the requested ID could not b...
- Help with 409 Error on Relationship Setu...
I ran into a 409 document_already_exists issue. with AppWrite so I tried to debug. Here's what I've set up: Collection A has 3 attributes and a two-way 1-to-m...
- Database Double Requesting Error.
I am getting error for creating new document in an collection with new ID.unique() then too getting error of existing document. When button is pressed one docum...
