I'm aware of this q/a about bypassing the cache in firebase, but I'd like to do the same in firestore, and do so with listeners...
My code at present does this...
FIRQuery *query = [[db collectionWithPath:@"mycollection"] queryWhereField:@"uid" isEqualTo:user.uid];
[query addSnapshotListener:^(FIRQuerySnapshot *querySnapshot, NSError *error) {
//...
This works fine, except it is prone to give me old data (or data after it has been deleted at the source). What I'd like to do is, something like...
if (/*some time has passed*/ || /*first time this launch*/) {
// magic to force the query to bypass anything cached
}
FIRQuery *query = [[db collectionWithPath:@"mycollection"];
// and so on...
The best seeming answer to that other question suggests using a transaction...
[db runTransactionWithBlock:^ id(FIRTransaction *transaction, NSError **error) {
// stuck
but FIRTransaction
has only one read-related method, which is to getDocument:error:
passing a FIRDocumentReference *
.
Also - future editors: I'm writing in objective-c, but I'm happy to read suggestions in swift. If you decide to delete the swift tag, please explain how someone expresses a question in either language. (Please note: the statement "we only use language tags to ask questions about the language itself" is provably false).