Programatically I've been able to implement rules and a client side query for my realtime database that can find if a Username under a users table exists or not. Before creating the ".indexOn": "username" rule, I was getting a warning that the client was downloading all the data and filtering it client side.
My question is what exactly does the ".indexOn" do? I'm not getting that warning anymore, so I'm curious what is being sent to the client now? Is it only the usernames and nothing else that's being sent and filtered?
Why is the filtering/querying not being done on the firebase server and sending back the resulting user instead, wouldn't that be more efficient/safe?
My query is
db.database.ref(`/users`).orderByChild('username').equalTo(control.value)
.once("value").then(res => {
return res.exists() ? {usernameTaken : true} : null;
})
and my data is structured as:
"users": {
"UID": {
"username" : "exampleName"
}
}
Just trying to get a better understanding of how/what is happening, thank you!
Please let me know if more information is needed.