【发布时间】:2020-09-17 19:03:20
【问题描述】:
我想写一个云函数来监听是否在users的某个文档的following子集合中创建了一个新文档。但是,之前创建的用户文档可能没有following 子集合。
换句话说,我想要一个响应db.collection(“users”).doc(“doc_id1”).collection(“following”).doc(“doc_id2”).set(new_document) 的云
,并且我已经将云函数写成了
exports.create_friend_request_onCreate = functions.firestore
.document("users/{user_id}/{following}/{following_id}")
.onCreate(f2);
f2 的实现写在其他文件中
exports.f2 = async function(snapshot) {
//some code
}
但是在子集合中创建文档时,我收到以下错误
Error: Value for argument "documentPath" is not a valid resource path. Path must be a non-empty string.
谁能给我解释一下这里出了什么问题?
【问题讨论】:
标签: node.js firebase google-cloud-firestore google-cloud-functions