我正在創建我的第一個云函數,它在創建后將子集合中的文檔簡單地復制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 模擬器調試它嗎?
復制文檔的簡單云功能出錯
慕田峪4524236
2023-05-18 10:45:39