Skip to content

Firebase database – filtering and ordering query

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);

Database looks like :

  name: "a Name"
  name: "other Name"

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?


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