键必须是非空字符串,不能包含“.”、“#”、“$”、“/”、“[”或“]”
Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"
我正在尝试使用管理员权限在 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 或奇怪的值)
您只能将完整路径传递到 update
,所以最后一行应该是:
return admin.database().ref().update(updatedBidQuote)
对我来说,我有不必要的大括号。我从
return admin.database().ref().update( {updateObj} );
至
return admin.database().ref().update(updateObj);
我正在尝试使用管理员权限在 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 或奇怪的值)
您只能将完整路径传递到 update
,所以最后一行应该是:
return admin.database().ref().update(updatedBidQuote)
对我来说,我有不必要的大括号。我从
return admin.database().ref().update( {updateObj} );
至
return admin.database().ref().update(updateObj);