【发布时间】:2019-09-15 22:03:53
【问题描述】:
我想从我的 Firestore 数据库中删除一个文档。但我的代码只会让我删除所有文档。不知何故,我需要获取与我正在滑动的 tableview 中的行相对应的 DocumentID。有什么建议么?
我的代码是这样的;
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
self.db.collection("Miljoskjema").getDocuments { (snapshot, err) in
if let err = err {
print("Error getting documents: \(err)")
} else {
for document in snapshot!.documents {
document.reference.delete()
}
}}}
【问题讨论】:
-
你知道文档id吗?
-
快照获取所有文档ID。但我不知道如何将 tableview 中的选定行引用到战斗文档 ID
标签: swift google-cloud-firestore document