这是一份文件" TestAccount"它拥有2个系列。当我查询" TestAccount"有没有办法知道集合名称?文件?
这不会打印出集合名称:
db.collection("users").document("TestAccount").getDocument { (allDocs, allDocsErrors) in
guard let _allDocs = allDocs,
allDocs?.exists ?? false,
allDocsErrors == nil else {
print("early exit \(allDocs?.exists)") //always fires
return
}
答案 0 :(得分:0)
结帐此代码,我从allDocs?.exists ?? false,allDocsErrors == nil
条件列表中移除guard
,这应该可以正常工作
db.collection("users").document("TestAccount").getDocument
{
(documentSnapshot, error) in
guard let documentSnapshot = documentSnapshot else {
print("early exit \(documentSnapshot?.exists)");
return
}
let children = documentSnapshot.data();
for (id , value) in children
{
print(id);
}
}