如何正确地查询一个由映射组成的数组字段。
目前的结构是
Collection1
Document1
-papers: <---- This is an array
(0):
-Name:abc
-Id:123
(1):
-Name:xyz
-Id:456
这是我的代码
DocumentReference docRef = db.collection("Collection1").document("Document1");
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document != null && document.exists()) {
//?? how can I retrieve papers
}
}
});
基本上,我会将其检索并转换为ArrayList>,然后循环遍历以创建最终的ArrayList吗?
还是它是如何工作的?