【发布时间】:2018-11-23 07:02:28
【问题描述】:
我是 ios 新手,请考虑..我有集合,因为 organisationStandardTemplate 下面是添加的屏幕截图...我想将来自**roles** array list 的数组列表存储在文档中。 p>
这是 android 代码,它的工作正常,与我在 iOS 中使用的一样 快速的语言..
FirebaseFirestore db = FirebaseFirestore.getInstance();
db.collection("organisationStandardTemplate")
.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()){
if (task.getResult() != null) {
for (DocumentSnapshot documentSnapshot : task.getResult()){
if (documentSnapshot.exists()) {
try {
orgTemplate = (ArrayList<HashMap>) documentSnapshot.get("roles");
} catch (Exception e){
Log.e("Excep", e.getMessage());
}
}
}
}
}
}
});
IOS 代码
func organisationStandardTemplate(){
var orgTemplate = [AnyObject]() // here i crated my array list
let db = Firestore.firestore()
db.collection("organisationStandardTemplate").getDocuments() { (querySnapshot, err) in
if err != nil{
// print("\(document.documentID) => \(document.data())")
}else {
orgTemplate = //How to get and store into my orgTemplate array list
}
}
}
}
文档 https://firebase.google.com/docs/firestore/query-data/get-data
注意:我只有一份文件,但我不想根据 DocumentID 因为我有两个数据库,比如测试和生产所以 每次我无法更改内部代码..
【问题讨论】:
标签: ios swift google-cloud-firestore