2

I am trying to update only the $key of an object from my Firebase database. All the values in the object I want to keep untouched. I tried this way:

this.af.object('personalMessages/'+ firebase_uid).update({ $key: 'my custom key' })

I get no error, but the record is not updating.

The big objects looks like this:

personalMessages:{
     the_key_I_want_to_update:
    {
         isRead:  false
         text: "some text goes here"
         timestamp:   1502448955231.222

    }
}
Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474
Emanuela Colta
  • 2,129
  • 4
  • 18
  • 31
  • 1
    I think there is no way to update the key. You need to retrieve the value in a key, then store value in a new key and remove old key. – Prajeet Shrestha Sep 13 '17 at 08:39
  • 1
    It's seems that the only solution is to remove the old key and create a new one with the new name. https://stackoverflow.com/questions/39107274/is-it-possible-to-rename-a-key-in-the-firebase-realtime-database – stiGVicious Sep 13 '17 at 10:16
  • This was, also, the soution I've implemented, but it causes other bugs. Thank you, anyways, for the response! :) – Emanuela Colta Sep 13 '17 at 11:55

0 Answers0