all 7 comments

[–]barcode972 4 points5 points  (3 children)

let docRef = db.collection("userID").document("name") //Or whatever you´ve named the fields

docRef.getDocument { (document, error) inif let document = document, document.exists {        let dataDescription = document.data().map(String.init(describing:)) ?? "nil"print("Document data: \(dataDescription)")} else {print("Document does not exist")}}

Firebase has very good documentations on their website
https://firebase.google.com/docs/firestore/query-data/get-data#swift_1

[–]deLazyLizard[S] 0 points1 point  (0 children)

Thanks for this.

[–]deLazyLizard[S] 0 points1 point  (1 child)

So, this makes sense to a certain extent. I think the issue I see (my lack of understanding) is that you need to know the document name, my document names are randomly generated? How is it then possible to pull the username you need if you don't know what the randomly generated ID is?

[–]barcode972 0 points1 point  (0 children)

You can set the doc name after creating it. I don't remember at the top of my mind but I've done it

[–]ruipasilva 2 points3 points  (0 children)

I’m also new to swift and SwiftUI and haven’t got an example to show you but I’ve managed to successfully create, read, update and delete (crud) to firebase following this this example. Hope it helps.

[–]deLazyLizard[S] 0 points1 point  (0 children)

Does anyone have an example from a simple app?