I am writing a polling app with Firebase backend. Users answer to yes/no questions and see results. They can't see who answered the question though, except their friends. My structure:
questions
question1:
readable
text: "Do you enjoy Stack Overflow?"
yes_count: 76
no_count: 14
response:
user1: yes
user2: no
...
user1000: no
users:
user1:
friends:
user1
user999
One way to do this is just calling onChildAdded
on the "response"
node, and do filtering on client side. This may result in downloading thousands of unnecessary UIDs. Another way is to ask server to do it. Users put requests to get friends' UIDs on a queue, backend does the filtering and puts it at a location that users can listen to. But this is a big extra load, especially considering whenever there is a new answer to a question, the backend has to check whether that new answer is from a friend for every user.
Question: is it possible to query Firebase in such a way to get only friends' UIDs at "response"
node, instead of everyone's. If not, is it better for users to do filtering (and downloading thousands of un-needed UIDs), or for server to do it (huge extra load)?