我想要找出Firebase文档中的字段总数。我该怎么做呢?
发布于 2019-02-14 00:53:48
要获取特定文档中的字段数量,请使用以下代码行:
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
DocumentReference docRef = rootRef.collection("yourCollection").document("yourDocument");
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document.exists()) {
Map<String, Object> map = document.getData();
Log.d(TAG, String.valueOf(map.size()));
}
}
}
});https://stackoverflow.com/questions/54675346
复制相似问题