无法读取的未定义的属性“数据”我有以下的云功能:火力地堡云功能 - 类型错误:当数据存在
exports.keepPostKeysUpdated = functions.database.ref('/posts/{postid}').onWrite(event => {
console.log("write on posts...");
console.log(event.previous.params.postID);
console.log(event.data.previous.val());
console.log(event.data.previous.val().postID);
var postKey = event.data.previous.val().postID;
// When a table, category, or region is changed the old upload has to be deleted
if (event.data.previous.exists()) {
if (event.data.previous.val().table != event.data.val().table || event.data.previous.val().region !=
event.data.val().region || event.previous.data.val().category != event.data.val().category) {
// category, region, or table was changed
console.log(postKey);
if (event.data.previous.val().table != event.data.val().table) {
console.log("Table was changed");
// delete the post from the old table
const oldTable = event.data.previous.val().table;
const newTable = event.data.val().table;
addToNewTable(newTable, postKey);
removePostFromOldTable(oldTable, postKey);
}
if (event.data.previous.val().category != event.data.val().category) {
console.log("Category was changed");
// delete the post from the old category
const oldCategory = event.data.previous.val().category;
const newCategory = event.data.val().category;
addToNewCategory(newCategory, postKey);
removePostFromOldCategory(oldCategory, postKey);
}
if (event.data.previous.val().region != event.data.val().region) {
console.log("Region was changed");
// delete post from old region
const oldRegion = event.data.previous.val().region;
const newRegion = event.data.val().region;
addToNewRegion(newRegion, postKey);
removePostFromOldRegion(oldRegion, postKey);
}
}
else {
return
}
}
else {
// previous value does not exist this case is handled by
// copyPostKey
return
}
});
当一个表或区域被改变它的工作完全正常,但无法每次类别被改变。错误来自行var postKey = event.data.previous.val().postID;
这个值如何被读取一些而不是其他的?我甚至可以通过控制台登录密钥,但是当我尝试将其分配给postKey时,它表示无法读取密钥。任何想法这个问题是从什么?
的数据总是从我的iOS应用
ref.child("posts").child(editedPost.postID).updateChildValues(["table": editedPost.table])
ref.child("posts").child(editedPost.postID).updateChildValues(["category": editedPost.category])
ref.child("posts").child(editedPost.postID).updateChildValues(["region": editedPost.region])
节点= v6.11.2 火力工具编写同样的方式= 3.10.10