[英]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.我正在尝试使用管理员权限在 firebase 函数上一次写入两个地方。 Getting this strange error:
得到这个奇怪的错误:
Error: Firebase.set failed: First argument contains an invalid key (/Auction/TD6MKEhS/-Kn9cMUPkk)
错误:Firebase.set 失败:第一个参数包含无效密钥 (/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)我检查了 postData 的对象并且没有任何(.keys 或奇怪的值)
您只能将完整路径传递给update
,因此最后一行应该是:
return admin.database().ref().update(updatedBidQuote)
For me, I had unnecessary curly brackets.对我来说,我有不必要的大括号。 I changed from
我从
return admin.database().ref().update( {updateObj} );
to到
return admin.database().ref().update(updateObj);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.