我正在创建我的第一个云函数,它在创建后将子集合中的文档简单地复制journal到子集合中。activites我希望复制的文档具有相同的postId. 功能日志显示
Error: Value for argument "documentPath" is not a valid resource path. Path must be a non-empty string.
at Object.validateResourcePath (/workspace/node_modules/@google-cloud/firestore/build/src/path.js:406:15)
at CollectionReference.doc (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:1982:20)
at exports.onCreateJournal.functions.firestore.document.onCreate (/workspace/index.js:21:8)
at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:134:23)
at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:198:28)
at process._tickCallback (internal/process/next_tick.js:6
这是云函数
exports.onCreateJournal = functions.firestore
.document("/users/{userId}/journal/{docID}")
.onCreate(async (snapshot, context) => {
const data = snapshot.data();
const userId = context.params.userId;
const postId = context.params.postId;
admin
.firestore()
.collection("users")
.doc(userId)
.collection("activities")
.doc(postId)
.set(data);
});
或者我应该用 Firestore 模拟器调试它吗?
肥皂起泡泡
相关分类