HomeiOS Developmentios - Methods to fetch the worth of a subject in a...

ios – Methods to fetch the worth of a subject in a doc in Firestore database


I’ve this code that fetches my knowledge from my BJ doc in my Firestore Database.


docRef.getDocument(as: Metropolis.self) { end in
    // The Outcome kind encapsulates deserialization errors or
    // profitable deserialization, and might be dealt with as follows:
    //
    //      Outcome
    //        /
    //   Error  Metropolis
    swap outcome {
    case .success(let metropolis):
        // A `Metropolis` worth was efficiently initialized from the DocumentSnapshot.
        print("Metropolis: (metropolis)")
    case .failure(let error):
        // A `Metropolis` worth couldn't be initialized from the DocumentSnapshot.
        print("Error decoding metropolis: (error)")
    }
}

With this class :

public struct Metropolis: Codable {

    let title: String
    let state: String?
    let nation: String?
    let isCapital: Bool?
    let inhabitants: Int64?

    enum CodingKeys: String, CodingKey {
        case title
        case state
        case nation
        case isCapital = "capital"
        case inhabitants
    }

}

I must get the worth of the “road” subject that is within the BJ doc. I am actually caught. Does anybody have a approach to get the worth of the fields in a firestore database ?
I can not discover nothing within the documentation. Like how are you aware the values of the fields in paperwork?

I already tried with customized lessons and i am unable to get the values of some fields, I simply get the whole lot without delay.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments