I’m working on a React Native app, and trying to set up a user research in the database, based on a given text.
Here is my request code :
const ref = firebase.database().ref().child('allUsers');
const query = ref.orderByChild("name").startAt(text).endAt(text+'uf8ff').limitToFirst(20);
query.once('value',(snapshot)=>{...});
Database looks like :
allUsers anUserUid name: "a Name" ...otherinfos... anOtherUserUid name: "other Name" ...otherinfos... ...otherusers...
The query returns what I want, but I have an error on each query only saying “@firebase/database:”. And nothing else…
How can I fix it?
Advertisement
Answer
Most likely it is a warning about no index.
Try adding an index to your data. You can do that by adding the following to the database.rules.json file:
{
"rules": {
"allUsers": {
".indexOn": ["name"]
}
}
}
And deploying.
Or by editing the rules in the Firebase Console.
As described in the indexing data documentation page