【发布时间】:2023-03-30 03:28:01
【问题描述】:
如何访问另一个数组中的数组中的映射的id? 我在这里附上了火库结构 db structure in firestore
【问题讨论】:
-
你可以使用
Products.0.sub_products.0.city。
标签: firebase google-cloud-firestore
如何访问另一个数组中的数组中的映射的id? 我在这里附上了火库结构 db structure in firestore
【问题讨论】:
Products.0.sub_products.0.city。
标签: firebase google-cloud-firestore
在你成功的firestore请求监听器中,你可以得到这样的数组!
List<String> group = (List<String>) document.get("arrayfieldname");
【讨论】:
这是我的代码.. 我在这里使用了两个 where 条件,如您所见,您必须转到该集合的引用并添加 .where("fieldnameinfirestore", "yourvalue")..
private void GetCityListsnames() {
db.collection("citylist").document("city").
collection(uservolcity).whereEqualTo("complete","false").
whereEqualTo("takebyvol","false")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
mlistsproper.add(new VolListProperDataModel(document.getId(),document.getString("listname"),
document.getString("sendinguserphone"),
document.getString("sendingusername"),
document.getString("deliveryaddress"),uservolcity));
}
if(mlistsproper.size() == 0){
nolist.setVisibility(View.VISIBLE);
}
progressBar.setVisibility(View.INVISIBLE);
mAdapter.notifyDataSetChanged();
GetAccptListsnames();
} else {
Log.d("Errorgeetingaddres", "Error getting documents: ", task.getException());
Toast.makeText(getActivity().getApplicationContext(),
"Make sure you have added delivery address", Toast.LENGTH_SHORT).show();
}
}
});
}
【讨论】: