Firebase Firestore :如何在Android上将文档对象转换为POJO
2022-09-01 07:35:35
使用实时数据库,可以做到这一点:
MyPojo pojo = dataSnapshot.getValue(MyPojo.Class);
作为映射对象的一种方式,如何使用?Firestore
法典:
FirebaseFirestore db = FirebaseFirestore.getInstance();
db.collection("app/users/" + uid).document("notifications").get().addOnCompleteListener(task -> {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document != null) {
NotifPojo notifPojo = document....// here
return;
}
} else {
Log.d("FragNotif", "get failed with ", task.getException());
}
});