'firestore wherefield result is <FIRQuery> in swift

my code is here and result

  func documentField(){
        guard let uid = Auth.auth().currentUser?.uid else {
            return
        }
        print(uid)
        let db = Firestore.firestore().collection("collection")
        let data = db.orderby(by: "users").whereField("users", arraycontains: uid)
        print(data)
}
console outline

MNDJR2NOx1gOcxPGJ2xOUw3PHCM2
<FIRQuery: 0x6000032555e0>

i dont know where is my fault this query result is every time comig <FIRQuery: 0x6000032555e0>

enter image description here



Solution 1:[1]

Your code creates a query, but doesn't execute it. So that means you're printing the query itself, not its results.

If you have a look at the documentation on getting documents from the database, you'll find this Swift example of how to do so:

db.collection("cities").whereField("capital", isEqualTo: true)
    .getDocuments() { (querySnapshot, err) in
        if let err = err {
            print("Error getting documents: \(err)")
        } else {
            for document in querySnapshot!.documents {
                print("\(document.documentID) => \(document.data())")
            }
        }
}

You're going to want to call getDocuments() on your query in the same way and process the results you get.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Frank van Puffelen