显示firebase云中特定/当前/登录用户的数据

时间:2018-06-05 20:05:58

标签: android firebase google-cloud-firestore

任何人都可以在Firestore中对这种结构发表意见吗?

我想显示当前登录用户的数据。 让我们说我的应用中有一些用户:

我希望查询类似于firebaseFirestore.collection(" Complaints")。document(user_id).addSnapshotListener(new EventListener()

这是我的代码:

firebaseFirestore.collection(" Complaints")。addSnapshotListener(new EventListener(){             @覆盖             public void onEvent(QuerySnapshot documentSnapshots,FirebaseFirestoreException e){

            for (DocumentChange doc: documentSnapshots.getDocumentChanges())
            {
                if (doc.getType() == DocumentChange.Type.ADDED)
                {
                    Complaints complaints = doc.getDocument().toObject(Complaints.class);
                    complaintsList.add(complaints);

                    complaintsRecyclerAdapter.notifyDataSetChanged();
                }
            }
        }
    });

1 个答案:

答案 0 :(得分:1)

通常这是一个很好的结构

this.$auth