
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
- Looking for Partner
I'm looking for a partner for long-term collaboration. Of course, you'll get paid for it. If you are interested, please send a DM to me
- 2 Columns still processing since yesterd...
Hey o/ Yesterday (around <t:1758045600:f>), I created a database and added several columns to it. After about 15 minutes, most of the "processing" tags disappe...
- 503 Timeout when Updating or Upserting D...
Hey I’m running into an issue when trying to update or upsert a row in Appwrite. The request hangs for a while and then throws this error: ``` AppwriteException...
