how to get authenticated user data in firestore android

Viewed 132

I have a Firestore database see the image below. I want to retrieve the doctor's info. All of these documents under "doctors" collection are from authenticated users and I have saved the documents with their IDs. I am using this code to get the documents but it returns 0. I think the problem is authentication. Kindly help me to solve this issue.

 val query = fireStoreDbRef.collection(Constants.COLLECTION_DOCTORS)
        query.get().addOnSuccessListener {
        Log.d("TAG", "getAllDoctors: "+it.size())
    }

enter image description here

Security Rules I am using enter image description here

1 Answers

It's possible to see in your screenshot that the documentIds are in italic, this indicates that the documents you were trying to access were deleted. If you were to add a new document the code you currently have for fetching documents is suppose to work normally.

As per the reason why those documents were deleted, the most probable is that they were deleted by someone else operating this Firestore, unfortunately there are no native log solutions for Firestore for you to audit that. In fact, it is recommended that you build a logging solution for your Firestore with the use of Cloud Functions, if you fell it is necessary, here is an example in a community answer for how to do that.

If this is not the case I would advise you to keep an eye out for this behaviour, and if it should happen again I would recommend you to open a Bug Report on Google's Issue Tracker so that this can be troubleshooted by Google's Engineering team

Related