How to use the orderByKey and EqualTo of Firebase?

0

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

The data I have is as follows:

  

this._userID = ALIANSCE

     

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

     

What I do not have is the name of "FLOOR" that I need to find from   according to what I said above.

I get the following notification in the console:

  

util.js: 189 FIREBASE WARNING: Using an unspecified index. Your date   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 as follows:

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

    };
    
asked by anonymous 26.01.2018 / 19:52

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 rule location:

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

I hope I have helped.

    
04.04.2018 / 20:26