I was wondering, is there a way to update the key value?
Let´s use the following data:
I am using set() to write the data.
Now, I want the user to edit their bookTitle
and it needs to change on both places. I tried using update() but I can´t seem to make it work. I can only edit the bookTitle
in bookInfo
NOT on books
.
Moving is not an option because it will erase the bookData
.
I also tried writing using push() but then, I can´t search properly because I don´t have the pushID (I need the search because users can't have two books with the same name)
So, is there a way to update the key value? or, is there a better approach to this? I accept suggestions. Thank you!
Update: This is what I´m currently using to update the book title inside bookInfo
var bookName = document.getElementById('bookName').value;
firebase.database().ref('books/' + bookName + '/bookInfo').update({
bookTitle : bookName
});