我希望當用戶已經按下downvote時,下次按下投票按鈕時,它們將從downvote字典中移除。爲什麼要移除Firebase中的數據removeValue()不起作用?
Firebase.getDownvote(selectedPostTimeStamp: postItem.timeStamp) { (error, downvoteFinalDictionary) in
let keyExists = downvoteFinalDictionary?[Current.user.userID!] != nil
// if the current user exists in the downvote dictionary
if keyExists {
print("Current UID exist")
// remove the current user from the downvote dictionary
self.databaseRef.child("channels").child(Current.user.channel).child("posts").child("post").child(Current.user.userID!).removeValue()
} else {
// uid doesn't exist
}
我也試過這個:(
self.databaseRef.child("channels").child(Current.user.channel).child("posts").child("post").child(Current.user.userID!).removeValue(completionBlock: { (error, databaseReference) in
print("\n\n\n DATA IS SUPPOSED TO BE GONE!!!!!")
})
你能告訴我們你的'channels'結構嗎? – dstepan
@dstepan你去了,我只是編輯了顯示「頻道」的圖片:) –