Ключи должны быть непустыми строками и не должны содержать ".", "#", "$", "/", "[" Или "]"
Я пытаюсь написать с правами администратора два места одновременно на функциях Firebase. Получение этой странной ошибки:
Ошибка: сбой Firebase.set: первый аргумент содержит недопустимый ключ (/Auction/TD6MKEhS/-Kn9cMUPkk)
Мой код:
var newPostRef = admin.database().ref().child("History/" + this.customeruid + '/' + this.quoteid + '/' + this.banuid).push();
var newPostKey = newPostRef.key;
var updatedBidQuote = {};
// Create the data we want to update
let postData = { creationBidDate: admin.database.ServerValue.TIMESTAMP, customeruid: this.banuid, quoteCompanyCreatoruid: this.customeruid, Amount: this.banBid };
updatedBidQuote['/Auction/' + this.customeruid + '/' + this.quoteid] = postData;
updatedBidQuote['/History/' + this.customeruid + '/' + this.quoteid + '/' + this.banuid + '/' + newPostKey] = postData;
return admin.database().ref().set(updatedBidQuote);
Я проверяю объект postData и не имею никаких (.keys или странное значение)
1 ответ
Решение
Вы можете только пройти полный путь в update
поэтому последняя строка должна быть:
return admin.database().ref().update(updatedBidQuote)
Для меня возникли ненужные фигурные скобки. Я изменил с
return admin.database().ref().update( {updateObj} );
к
return admin.database().ref().update(updateObj);