I am very new in this firestorm and database management.
In my code, there are plenty of group documents in a groups collection Now what I want to do is, show a person from users collection the specific groups he is connected to.
here is how the groups uids look:

here is how the document of user looks:

The code I use to create the group document is this after creating the document I add the uid of the new document to the user's array called groups.
Future createNewGroupData(String groupName) async {
String _userID = await getUID();
return await groupCollection.add({
'creatorUID': _userID,
'groupName': groupName,
'teachers': [_userID],
}).then((ref) => {
userCollection.document(_userID).updateData({'groups': FieldValue.arrayUnion([ref.documentID])})
});
this is the structure of how I create the document for each user,
Future updateUserData(int avatarID, String firstName, String lastName, String status, List groups, String school) async {
return await userCollection.document(uid).setData({
'avatarID': avatarID.round(),
'firstName': firstName,
'lastName': lastName,
'status': status,
'groups': groups,
'school': school,
});
}
How I implemented that was when the user was added to a group. The uid of that group was appended in an array under that user's documents.
Now what I want to do is get a stream of snapshots of the groups only uids are present in that user's array. I can not really find any way to implement that.