I'm looking for some guidance on the most optimal way for my application to retrieve user data from Firebase.
For the data structure, I have a db where I have added a "users" child node, and which I then add any user key which has access to this data. For example it looks like.
- users
- 32408fhaidsf=sd0ofds : true
- dd044540-v04r5-0824f: true
- 43fr45ghh34ggh5567jh: true
I use the OrderbyChild option per the code below. This does work...however I get the firebase warning message: "@firebase/database: FIREBASE WARNING: Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ".indexOn": "users/QHfNAoleVsfhLJt9dTenCkpCeVu2" at /channels to your security rules for better performance. "
My concern is that as the size of the data grows, is it actually downloading entire table to the client here? That would be extremely problematic. At the same time, I can't see how I can add keys to the /users/ as I append/remove keys based on how users are interacting with the data. I definitely have the need to retrieve data where multiple users can have access to that data.
addListeners = () => {
let loadedChannels= [];
this.state.channelsRef.orderByChild(`users/${this.state.user.uid}`).equalTo(true).on('child_added', snap => {
if(snap.hasChildren())
{
loadedChannels.push(snap.val()); }