密钥必须是非空字符串,且不能包含"。","#"," $"," /& #34;," [",或"]"

时间:2017-06-22 12:28:08

标签: javascript firebase firebase-realtime-database firebase-admin

我正在尝试使用管理员权限一次在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或奇怪的值)

2 个答案:

答案 0 :(得分:3)

您只能将完整路径传递到update,因此最后一行应为:

return admin.database().ref().update(updatedBidQuote)

答案 1 :(得分:0)

对我来说,我有不必要的花括号。我从

return admin.database().ref().update( {updateObj} );

return admin.database().ref().update(updateObj);
相关问题