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
- delete document problems
i don't know what's going on but i get an attribute "tournamentid" not found in the collection when i try to delet the document... but this is just the document...
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...