How to Update a Key Name in Firebase?

0

I need to update the name of a Key in Firebase and then update a child of the same name.

I'm trying to do this:

AsyncUpdateMap(){
    this._userID = "Aliansce";
    this._mapID = Marker.MarkerId;

    this.locationROOT = this.FirebaseInstance.ref('users/' + this._userID).child('/LOCATIONS/' + this._mapID); 
    this.locationROOT.once('value').then((e) => {

        this.locationROOT.update({
            mapUid: this._mapID,

        }) .then((sucess) => { // Then do Set Location Root
            console.log("LOCATION ROOT ATUALIZADO COM SUCESSO");

            const SYSTEM_DATE_CLASS = new SystemDate();

            this.mapROOT = this.FirebaseInstance.ref('users/' + this._userID).child('/MAPS/' + this._mapID); 
            this.mapROOT.update({
                mapUid: this._mapID,
                mapDates: {
                    dateEdit: SYSTEM_DATE_CLASS.DateIso 
                }
            }) .then((sucess) => { // Then do Set Map Root
                console.log("MAP ROOT ATUALIZADO COM SUCESSO")
            }) .catch((error) => { // Catch do Set Map Root
                console.warn("ERROR: " + error);
            });

        }) .catch((error) => { // Catch do Set Location Root
            console.warn("ERROR: " + error);
        }); 


    }) .catch((error) => { // Catch do Location Root
        console.warn("ERROR: " + error);
    });
}
    
asked by anonymous 06.02.2018 / 13:43

0 answers