The Firestore database is build of one collection of users. Every user document has some public data and a array of users ID's that he follows called following. In the Flutter app I would like to create a StreamBuilder on the following array. So when the user adds someone to his following array - it would be added to the stream, and when a user from the following list changes his data - the stream would update too.
I thought maybe to use a list of references ('users/usersid3'
) instead of a list of IDs ('userid3'
), but I don't know how to implement it.
This is how the database is structured.
users
- user1id
- some public data
- following: [user2id, user3id]
- user2id
- some public data
- following: []
- user3id
- some public data
- following: [user2id]