用于删除某些内容的代码(不适用于 this.task.id 或 this.task)
const docRef = firebase.firestore().collection('users').doc(firebase.auth().currentUser.uid)
docRef.collection('tasks').doc(this.task.id).delete()
答案 0 :(得分:0)
看起来您没有使用 then 或 async/await 处理 promise,就像文档中指出的 https://cloud.google.com/firestore/docs/manage-data/delete-data#node.js
一样。
此外,您的代码暗示任务嵌套在单个用户文档中。如果不是这种情况,您可能完全引用了错误的集合。我建议首先为用户和他们的任务做一个 .get().then(res => console.log(res))
。如果您无法获取该文档,则无法将其删除。