我要在创建新评论时用评论计数更新Blob文档。我想将触发器onCreate与打字稿一起使用。云存储可以做到吗?到目前为止,这是我所拥有的,但是我被困住了,因为在打字稿甚至节点上看不到太多文档。
exports.commentCreated = functions.firestore
.document('comments/{commentId}')
.onCreate((snap: any , context: any) => {
admin.firestore().collection("blob").doc(snap.data().blobId).get()
.then(snapshot => {
//1. count comment size? <-- how?
//2. update the blob with new comment count <-- how?
//below code is wrong
snapshot.update({
"commentCount": snapshot.size
});
})
.catch(error => {
console.log('22');
//response.status(500).send("Something went wrong!");
});
});