简体   繁体   English

键必须是非空字符串,并且不能包含“.”、“#”、“$”、“/”、“[”或“]”

[英]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.

相关问题 错误:Reference.child 失败:第一个参数是无效路径路径必须是非空字符串并且不能包含“.”、“#”、“$”、“[”或“]” - Error: Reference.child failed: First argument was an invalid path Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]" ESLint 7.1.0 错误:“模式”必须是非空字符串或非空字符串数组 - ESLint 7.1.0 Error: 'patterns' must be a non-empty string or an array of non-empty strings MessageEmbed 字段值必须是非空字符串 gamedig 问题 - MessageEmbed field values must be non-empty strings gamedig problem MessageEmbed 字段值必须是非空字符串 - MessageEmbed field values must be non-empty strings [Discord.js]MessageEmbed 字段值必须是非空字符串 - [Discord.js]MessageEmbed field values must be non-empty strings MessageEmbed 字段值必须是非空字符串。 帮助命令 - MessageEmbed field values must be non-empty strings. help command Javascript:非空字符串的“真实”值 - Javascript: “truthy” values for non-empty strings Firebase错误:提供给sendToDevice()的注册令牌必须是非空字符串或非空数组 - Firebase Error: Registration token(s) provided to sendToDevice() must be a non-empty string or a non-empty array Discord bot 无法创建嵌入 RangeError [EMBED_FIELD_VALUE]:MessageEmbed 字段值必须是非空字符串 - Discord bot not able to create the embed RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings Discord.js v13 [EMBED_FIELD_VALUE]:MessageEmbed 字段值必须是非空字符串 - Discord.js v13 [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM