2017-06-22 45 views
1

我想用admin权限写两个地方曾经在firebase功能。 得到这个奇怪的错误:

Error: Firebase.set failed: First argument contains an invalid key (/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

只能通过全路径为update,所以最后一行应该是:

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