gpt4 book ai didi

ios - 删除 Firebase 中的字典元素

转载 作者:行者123 更新时间:2023-11-28 08:32:59 24 4
gpt4 key购买 nike

我正在尝试删除 firebase 中的字典元素

enter image description here

我想删除对象:-

D8QmnOSH6vRYiMujKNXngzhdn992:“真”PendingFriendRequests/RhiZYyMF7STn1vyA27HjnJRsLYb2到目前为止,我已经想出了这个:-

FIRControllerClass.ref.child("PendingFriendRequests").child(FIRAuth.auth()!.currentUser!.uid).observeSingleEventOfType(.Value, withBlock: {(Snapshot) in

let dict = Snapshot.value! as! NSMutableDictionary

for each in dict {
print(each)

print(acceptedFriend)

if each.key as! String == acceptedFriend{
print(each.key)
dict.removeObjectForKey(each.key)
print(dict)
}
FIRControllerClass.ref.child("PendingFriendRequests").child(acceptedFriend).setValue(dict)
}
})

最佳答案

https://firebase.google.com/docs/firestore/manage-data/delete-data?authuser=0

var cityRef = db.collection('cities').doc('BJ');

// Remove the 'capital' field from the document
var removeCapital = cityRef.update({
capital: firebase.firestore.FieldValue.delete()
});

关于ios - 删除 Firebase 中的字典元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38466994/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com