代码之家  ›  专栏  ›  技术社区  ›  Riddhi

如何在swift中从firebase中删除子记录?

  •  0
  • Riddhi  · 技术社区  · 6 年前

    我想删除这个记录 firebase ,我不知道钥匙的名字。所以,我不知道怎么做。有人能帮我吗?

    获取数组的代码如下

    var databaseRefer : DatabaseReference!
      let userID = Auth.auth().currentUser?.uid
     databaseRefer = Database.database().reference(withPath: userID!)
     databaseRefer.observeSingleEvent(of: .value, with: { snapshot in
             if !snapshot.exists() { return }
              if snapshot.value is NSNull {
               print("not found")
                } else {
                    for child in snapshot.children {
                    let snap = child as! DataSnapshot
    
                       print(dict)
    
                       dict.forEach { item in
    
                           print(item.value)
                   }
                 }
           }
       })
    

    1 回复  |  直到 6 年前
        1
  •  2
  •   nslllava    6 年前

    https://firebase.google.com/docs/database/ios/read-and-write

    “删除数据的最简单方法是对数据位置的引用调用removeValue。”