当用户决定删除他的帐户时,我想删除用户发布的所有内容。检查孩子是否有具体的价值
所以我想通过数据库并删除包含他的userId的所有内容。
let userId = API.User.CURRENT_USER?.uid
API.Post.REF_POST.observeSingleEvent(of: .value) { (Post) in
if let dict = Post.value as? [String: Any] {
print("dict", dict)
let uid = dict["uid"] as? String
print(uid)
print(userId)
if uid == userId {
print("gefunden")
}else {
print("nichts")
}
}
}
这将打印出nil作为uid。 我仍然可以打印出所有的后期数据。
"posts" : {
"-Kt1h76YbyIqmSRkkLsv" : {
"bookmarkCount" : 0,
"caption" : "Helm ",
"characterCount" : 5,
"commentCount" : 0,
"creationDate" : 1.504357677437253E9,
"likeCount" : 0,
"photoUrl" : "https://firebasestorage.googleapis.com/v0/b/funcloud-8e84e.appspot.com/o/Posts%2F2B9606C8-E28D-4F69-9956-036192D36948?alt=media&token=2cd8712b-ca18-44a9-aa1d-d42e179a8eb7",
"ratio" : 1.5056179775280898,
"score" : -24,
"uid" : "hUhEPEg99HMkas6CqMXE4ZIyu472"
},
"-Kt1msnhcK4sxGKi5cae" : {
"bookmarkCount" : 0,
"caption" : "",
"characterCount" : 0,
"commentCount" : 0,
"creationDate" : 1.50435918759132E9,
"likeCount" : 0,
"photoUrl" : "https://firebasestorage.googleapis.com/v0/b/funcloud-8e84e.appspot.com/o/Posts%2F5E96D809-AF10-4FD7-B18A-4D138DDD4878?alt=media&token=16b9452b-25da-4f7b-9d93-80e557c91490",
"ratio" : 0.75,
"score" : 0,
"uid" : "hUhEPEg99HMkas6CqMXE4ZIyu472"
}
},
当currentUserId等于一个帖子,这意味着它已经被张贴正是用户的ID,我想删除整个帖子。
谢谢!
我只想删除用户相关的东西,而不是一切。所以重要的是要知道这个值是否真的存在。 –
对不起,我已经修复了我的答案 –
谢谢你,但是,如何检查孩子是否具有特定的价值? –