【发布时间】:2020-05-07 13:27:40
【问题描述】:
以下是我尝试使用 Firebase 云功能做的事情:
收听“public_posts”集合下的文档之一的更改。
判断是否在“public”字段中从真到假
如果为真,则删除触发该函数的文档
对于第 1 步和第 2 步,代码很简单,但我不知道第 3 步的语法。如何获取触发该函数的文档的引用?也就是说,我想知道下面空行的代码是什么:
exports.checkPrivate = functions.firestore
.document('public_posts/{postid}').onUpdate((change,context)=>{
const data=change.after.data();
if (data.public===false){
//get the reference of the trigger document and delete it
}
else {
return null;
}
});
有什么建议吗?谢谢!
【问题讨论】:
标签: javascript node.js firebase google-cloud-firestore google-cloud-functions