I have been trying (without success) to retrieve a list of users in a group from a Firebase database; and I was wondering if its possible based on my data structure (below), or is the problem my swift code (also below)
This is my Firebase structure:
Users
---- <UserID>
---------- Username
---------- Email
---------- etc...
Groups
---- <GroupID>
---------- GroupName
---------- CreationDate
---------- GroupAdmin
---------- etc...
UsersInGroups
------- UserID
---------- GroupID : true <---- User is in Group
With the above data structure is it possible for me to retrieve the list of all users
in the a particular group
?
Currently my swift code is as follows:
ref = Database.database()reference(withPath: "UsersInGroups")
handle = ref.queryOrdered(byChild: <userID>).queryEqual(toValue: true).observe(.value, ....
As you can imagine, it is not pulling the userID
where the groupID = true
!?
Lastly, I was wondering if this is possible: I would like to get a list of all the GroupEntries
a User has done.
the Firebase structure is as follows:
GroupEntry
-------- <GroupID>
--------------- <entryID> : <userID>
the is a dynamic and unique string (ex 3:8) and the userID is the user that created the entry.
The swift code is below:
ref = Database.database()reference(withPath: "GroupEntry")
handle = ref.child(<groupID>).queryEqual(toValue: <userID>).observe(.value, ...
Can anyone offer any assistance!?