1
    self.db.collection("tasks").document(Auth.auth().currentUser?.uid ?? "").collection("currentUser").whereField("Date", isEqualTo: date).getDocuments(source: .cache){ (querySnapshot, err) in
        self.task = []
    if  querySnapshot!.documents.isEmpty{
         self.firstView.alpha = 1
                   self.labelText.alpha = 1
     }
    else{
     self.firstView.alpha = 0
               self.labelText.alpha = 0
        if let snapshot = querySnapshot?.documents{
                 for doc in snapshot{
                     let data = doc.data()

                    if  let descS = data["Task Description"] as? String, let dateS = data["Date"] as? String, let titleS = data["Task Title"] as? String, let type1 = data["Type"] as? String{

                        let newTask = Tasks(title: titleS, desc: descS, date: dateS, type: type1, docId: doc.documentID)
                         self.task.append(newTask)

                        print(self.task)
                         DispatchQueue.main.async {
                            self.taskTableView.reloadData()
                         let indexPath = IndexPath(row: self.task.count - 1, section: 0)
                         self.taskTableView.scrollToRow(at: indexPath, at: .top, animated: false)

                         }



             }
         }

}

}

As you can see I am reading from the cache and not the server. Also I am not using a snapshot listener so there is no excuse for me to be charged with reads when I call this.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • 1
    It's not possible for us on Stack Overflow to diagnose where your reads are coming from. The most common misunderstanding is that the Firestore console causes reads to happen when left open on a collection that changes over time. But only you know for sure the usage patterns of your app and console. – Doug Stevenson Jun 14 '20 at 16:03
  • What do you mean left open? I have no snapshot listeners. How do I close it? Do you mean just close the browser? – Jeffrey Bennet Jun 14 '20 at 16:23
  • I'm talking about the Firebase web console in your browser. – Doug Stevenson Jun 14 '20 at 17:03

0 Answers0