In Firebase database, I am trying to update one column only. Firebase database 'users' JSON:
"users" : {
"5yty2c8TyChQu3fMJ1O3d44wuq2" : {
"Email" : "[email protected]",
"FirstName" : "John",
"LastName" : "Smith",
"MobileNumber" : "",
"NickName" : "",
"profile_picture" : ""
}
I would like to update just one column - MobileNumber with this code:
updateMobileNumber(){
var updateData = {
MobileNumber: this.state.mobileNumber
};
var updates = {};
updates['/users/' + userId ] = updateData;
database.ref('users/' + userId).update(updates);
alert('Account Updated');
}
The above code instead of updating MobileNumber column, it is removing all the other columns and adding Email column. What am I doing wrong ? I want to update Email column without touching other columns. Appreciate any help.