How do I use Firebase Equalto and orderByKey?

Asked

Viewed 586 times

0

I need to search my database, which "FLOOR KEY" is "main".

The data I have is as follows::

this. _userid = ALLIANCE

this. _mapID = MAP NAME THAT WAS CLICKED ON MARKER OF GOOGLE MAPS

What I don’t have is the name of the "FLOOR" that I need to find agreement with what I said above.

I get the following notification on the console:

util.js:189 FIREBASE WARNING: Using an unspecified index. Your data will be downloaded and Filtered on the client. Consider Adding ". indexOn": "floorType" at /users/Aliansce/MAPS/Viaparqueshopping/FLOORS/B30 to your security Rules for Better performance.

My code is this::

static AsyncQueryMainFloorMap(mapID){
        const GOOGLE_MAPS_STATIC_CLASS = GoogleMaps;

        this._userID = "Aliansce";
        this._mapID = mapID;
 
        this._mapFloorROOT = this.FirebaseInstance.ref('users/' + this._userID + '/MAPS/' + this._mapID).child('FLOORS');
        this._mapFloorROOT.once('child_added').then((mapFloorSnapshot) => {
            this._floorROOT =  this.FirebaseInstance.ref('users/' + this._userID + '/MAPS/' + this._mapID + '/FLOORS/').child('' + mapFloorSnapshot.key + '/');
            this._floorROOT.orderByChild('floorType').equalTo('main').once('child_added').then((e) => {
                console.log(e.key)
            });

            
        }) .catch((error) => {
            console.warn("error: " + error);
            // TODO
        });
  
    };

1 answer

0

I also spent a few hours trying to figure out what was wrong and why this message. Add the rule to your local rules:

{
   "rules": {
   ...,
   ...,
     "nome_tabela_ou_colecao": {
       ".indexOn": "floorType"
   }
  }
}

I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.