在firebase數據庫的firebase文檔中,有關於展開數據庫的信息,並且以消息應用程序爲例。如何從firestore文檔中檢索密鑰(使用swift 4/ios)
https://firebase.google.com/docs/database/web/structure-data
// Conversation members are easily accessible
// and stored by chat conversation ID
"members": {
// we'll talk about indices like this below
"one": {
"ghopper": true,
"alovelace": true,
"eclarke": true
},
"two": { ... },
"three": { ... }
},
在「成員」 /「一」的每個鍵是在聊天的參與成員的名稱。我很確定在firebase數據庫中有一個getKey方法來獲取每個密鑰。
我以類似的方式設置了我的數據庫(使用firestore而不是firebase),但每個聊天都是唯一的標識符,文檔包含聊天的成員,其中的密鑰是他們的firebase身份驗證ID。
var docsref: DocumentReference?
docsref = self.defaultStore?.colleection("chats").document(chatID)
docsref?.getDocument { (document, error) in
if let _ = document {
print("document!.data()")
} else {
print("Document does not exist")
}
}
當我輸出:
print(document!.data())
我得到[「2mHuccccxxxxxxxxxxk4wkIAt33」:1],這是參與聊天成員和一個布爾之一的火力授權碼。
我想獲得該密鑰,但不知道如何。
謝謝。