2017-06-22 47 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) 
相關問題