[英]How can i access/delete a randomly created document id in firestore?
Code for deleting something (not working with this.task.id or this.task)删除某些内容的代码(不适用于 this.task.id 或 this.task)
const docRef = firebase.firestore().collection('users').doc(firebase.auth().currentUser.uid)
docRef.collection('tasks').doc(this.task.id).delete()
It looks like you are not handling the promise with a then or async/await, like the docs indicate https://cloud.google.com/firestore/docs/manage-data/delete-data#node.js
.看起来您没有使用 then 或 async/await 处理promise ,就像文档指出
https://cloud.google.com/firestore/docs/manage-data/delete-data#node.js
。
Also, your code implies the tasks are nested within the individual users document.此外,您的代码意味着任务嵌套在单个用户文档中。 If this is not the case, you might be referencing the wrong collection entirely.
如果不是这种情况,您可能完全引用了错误的集合。 I suggest first doing a
.get().then(res => console.log(res))
for both the user & their task.我建议首先为用户和他们的任务做一个
.get().then(res => console.log(res))
。 If you can't get the document, you can't delete it.如果您无法获取该文档,则无法将其删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.