Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"

I am trying to write with admin permission two places at once on firebase functions. Getting this strange error:

Error: Firebase.set failed: First argument contains an invalid key (/Auction/TD6MKEhS/-Kn9cMUPkk)

My code is:

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);

I check the object of postData and didnt have any (.keys or strange value)

like image 481
Vitaly Menchikovsky Avatar asked Nov 24 '25 07:11

Vitaly Menchikovsky


1 Answers

You can only pass full paths into update, so the last line should be:

return admin.database().ref().update(updatedBidQuote)
like image 101
Frank van Puffelen Avatar answered Nov 26 '25 19:11

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!