I'm doing a simple query and periodically Firestore doesn't return anything. No error, no results, nothing.
Firestore.firestore().collection("groupChats")
.order(by: kUpdatedAt, descending: true)
.whereField("memberIds", arrayContains: currentUserId)
.limit(to: 15).getDocuments { [weak self] snapshot, error in
// nothing inside here ever hits
}
I'm not really sure how to proceed or debug this since this seems to be inside of Firestore. The user has an internet connection. Pulling to refresh and calling that query again returns the same seeming no-op result.
Any ideas what's going on here? Thanks!
In Firestore there's just no such thing as an "empty collection" and we have no mechanism today to "create" collections or "delete" collections other than by writing a document (to "create" the collection) and deleting all the documents (to "delete" the collection).
There are two ways to retrieve data stored in Cloud Firestore. Either of these methods can be used with documents, collections of documents, or the results of queries: Call a method to get the data. Set a listener to receive data-change events.
Firebase offers two cloud-based, client-accessible database solutions that support realtime data syncing: Cloud Firestore is Firebase's newest database for mobile app development. It builds on the successes of the Realtime Database with a new, more intuitive data model.
You can listen to a document with the onSnapshot() method. An initial call using the callback you provide creates a document snapshot immediately with the current contents of the single document. Then, each time the contents change, another call updates the document snapshot.
The issue ended up being caching is turned on by default and I had a massive cache on the device from development and migrations. Turning the offline caching off as part of the Firestore()
initialization helped this significantly and made my app usable again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With