在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],这是参与聊天成员和一个布尔之一的火力授权码。
我想获得该密钥,但不知道如何。
谢谢。