How to read a Firestore document?

Asked

Viewed 195 times

1

I need to know how to read a specific document I saved on Firestore, without having to copy "documentPath" manually from the Firestore Cloud Console!

How does it automatically?

Next, I put part of the code where is the "documentPath" that I need to configure:

DocumentReference user = mFirestore.collection("Usuarios").document(idUsuario).collection("Empresas").document(**"documentPath"**)

1 answer

-1

    Dim db As FirestoreDb = FirestoreDb.Create(projectId)

    Dim dadosCollections = dbCollections.BuscarColecoesFirebase(projectId)

    For Each eDados As NCollections In dadosCollections
        nColecao = eDados.Collections
        nDocumentReference = eDados.DocumentReferencia
    Next

    Dim docUsuario As CollectionReference = db.Collection(nColecao)
    Dim DocLista As DocumentReference = docUsuario.Document(Alertas.EmailUsuario)
    Dim mapCloudFirestore As New SPush

    'Dim docUsuario1 As CollectionReference = DocLista.Collection(nDocumentReference)
    'Dim verificaDocument As DocumentReference = docUsuario1.Document

    Dim Query As Query = docUsuario.WhereEqualTo("StatusLido", "N")

    Dim QuerySnapshot As QuerySnapshot = Await Query.GetSnapshotAsync()
    For Each documentSnapshot As DocumentSnapshot In QuerySnapshot.Documents

        Dim doc As String = documentSnapshot.Id
        Dim snapshot As DocumentSnapshot = Await DocLista.GetSnapshotAsync()
    Next

I do it this way in Vb.net see if it gives a light there for you.

  • 1

    It would be useful to add a small explanation to this code.

  • You can explain what this code does?

  • it queries a firebase document Dim Query As Query = docUsuario.Whereequalto("Statuslido", "N") Dim Querysnapshot As Querysnapshot = Await Query.Getsnapshotasync()
 For Each documentSnapshot As DocumentSnapshot In QuerySnapshot.Documents

 Dim doc As String = documentSnapshot.Id
 Dim snapshot As DocumentSnapshot = Await DocLista.GetSnapshotAsync()
 Next

Browser other questions tagged

You are not signed in. Login or sign up in order to post.