Firebase删除后无法创建文档

时间:2020-04-26 20:38:07

标签: ios swift firebase google-cloud-firestore

我的问题是,我通过应用程序创建了一个集合,然后通过应用程序删除了该集合,但我想再次创建它,但事实并非如此。当我外出并重新进入该应用程序时,便可以创建它。我的第一次创建和删除操作运行顺利。该应用程序未显示错误,但该程序继续运行,但没有形成数据火力地堡。 >

在此处创建数据代码:

db
    .collection("Cart")
    .document((Auth.auth().currentUser?.email!)!)
    .collection("Cart")
    .document().setData([
        "imageURL" : self.imageURL,
        "Foodname" : self.foodName,
        "Platecount" :self.plateCount,
        "Owneremail" :self.emailText,
    ])

删除代码在这里

self.db
    .collection("Cart")
    .document((Auth.auth().currentUser?.email!)!)
    .collection("Cart")
    .addSnapshotListener{ (snapshot, err) in
                         if err != nil {
                             print (err?.localizedDescription)
                         } else {
                             if snapshot?.isEmpty != true && snapshot != nil {
                                 for document in snapshot!.documents {
                                     self.db.collection("Cart").document((Auth.auth().currentUser?.email!)!).collection("Cart").document(document.documentID).delete()
                                 }
                             }
                         }
                     }

0 个答案:

没有答案