Query.orderByChild error: first argument was invalid path

Why am I getting this error when I want to query for the entire user url located next to the user's current url:

My code:

openMapPage()
  { 

    // GETTING THE CURRENT USER ADDRESS FOR LATITUDE AND LONGTITUDE
    var uid = firebase.auth().currentUser.uid;
    var ref = firebase.database().ref("request/" + uid);
    ref.once("value").then((snapshot) => { // <------ Here!
        var a = snapshot.exists();  // true
        var c = snapshot.hasChild("reqdetails"); // true
        var d = snapshot.child('reqdetails').exists();
        var requestsKey = snapshot.key;
        var requestsValue = snapshot.val();


       ref.once('value', (request) => {
  var currentUserAddress = request.val().regdetails.address;
  var geocoder = new google.maps.Geocoder();

  geocoder.geocode( { 'address': currentUserAddress}, (results, status) => {
    if (status == google.maps.GeocoderStatus.OK) {
      var latitude = results[0].geometry.location.lat();
      var longitude = results[0].geometry.location.lng();
      this.latlng = new google.maps.LatLng(latitude, longitude);
      //console.log("HAHAH current user");
      //var meterLimit  = this.latlng;
      //var userAddress = new LatLng(currentUserAddress);
      //console.log("SURESH IS COOL");
    } 
  }); 

});           

//END OF CURRENT USER 
}); 


  // GETTING THE ALL  USER ADDRESS FOR LATITUDE AND LONGTITUDE
    var ref1 = firebase.database().ref("request");
    ref1.once("value").then((snapshot1) => { // <------ Here!
        var a = snapshot1.exists();  // true
        var c = snapshot1.hasChild("reqdetails"); // true
        var d = snapshot1.child('reqdetails').exists();
        var requestsKey = snapshot1.key;
        var requestsValue = snapshot1.val();


        snapshot1.forEach((childSnapshot) => { // <------ And here!
            var requestKey = childSnapshot.key;
            var requestValue = childSnapshot.val();
            var reqdetails = requestValue.reqdetails;
            var AllUserAddress = requestValue.regdetails.address;




        var geocoder1 = new google.maps.Geocoder();

  geocoder1.geocode( { 'address': AllUserAddress}, (results, status) => {
    var limit = 10;
    if (status == google.maps.GeocoderStatus.OK) {
      var latitude1 = results[0].geometry.location.lat();
      var longitude1 = results[0].geometry.location.lng();
      this.latlng1 = new google.maps.LatLng(latitude1, longitude1);
      //var userAddress = new LatLng(currentUserAddress);
       //console.log(latlng1);
       var dist: number = parseInt((google.maps.geometry.spherical.computeDistanceBetween(this.latlng,this.latlng1) / 1000).toFixed(2));




       if(dist < limit)
       {
         console.log(dist);
         console.log(AllUserAddress);


    this.getRequest = this.angFire.list('request', {
      query: {
        orderByChild: AllUserAddress,
        startAt: 'regdetails'
      }
    })


       }


    } 
  }); 







        });


    });

  }

      

As you can see in this particular piece of code, I wanted to query all users that are near the user's current url: But that prevents me from doing that.

 this.getRequest = this.angFire.list('request', {
      query: {
        orderByChild: AllUserAddress,
        startAt: 'regdetails'
      }
    })

      

The error I am getting:

enter image description here

+3


source to share


1 answer


When you use startAt

, you must pass an object as the second argument with key and value. For example.startAt: { value: 'some-value', key: 'some-key' }.



Src: https://github.com/angular/angularfire2/blob/master/docs/4-querying-lists.md

+2


source







All Articles