aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Public/FIRQuery.h
diff options
context:
space:
mode:
authorGravatar rsgowman <rgowman@google.com>2018-04-18 10:30:37 -0400
committerGravatar GitHub <noreply@github.com>2018-04-18 10:30:37 -0400
commita5b3185ed372fc16b5430c230c197e3dbd34f953 (patch)
tree8f77610cf27ee35f5cccad825b6a33e74d7be8ef /Firestore/Source/Public/FIRQuery.h
parent6a39c71be83f589550c7dfa3c6d89d8b6145887c (diff)
Add GetOptions for controlling offline get behaviour (#655)
Add option to allow the user to control where DocumentReference.getDocument() and CollectionReference.getDocuments() fetches from. By default, it fetches from the server (if possible) and falls back to the local cache. It's now possible to alternatively fetch from the local cache only, or to fetch from the server only (though in the server only case, latency compensation is still enabled).
Diffstat (limited to 'Firestore/Source/Public/FIRQuery.h')
-rw-r--r--Firestore/Source/Public/FIRQuery.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/Firestore/Source/Public/FIRQuery.h b/Firestore/Source/Public/FIRQuery.h
index a28af39..946cf06 100644
--- a/Firestore/Source/Public/FIRQuery.h
+++ b/Firestore/Source/Public/FIRQuery.h
@@ -16,6 +16,7 @@
#import <Foundation/Foundation.h>
+#import "FIRFirestoreSource.h"
#import "FIRListenerRegistration.h"
@class FIRFieldPath;
@@ -44,6 +45,11 @@ NS_SWIFT_NAME(Query)
/**
* Reads the documents matching this query.
*
+ * This method attempts to provide up-to-date data when possible by waiting for
+ * data from the server, but it may return cached data or fail if you are
+ * offline and the server cannot be reached. See the
+ * `getDocuments(source:completion:)` method to change this behavior.
+ *
* @param completion a block to execute once the documents have been successfully read.
* documentSet will be `nil` only if error is `non-nil`.
*/
@@ -51,6 +57,20 @@ NS_SWIFT_NAME(Query)
NS_SWIFT_NAME(getDocuments(completion:));
/**
+ * Reads the documents matching this query.
+ *
+ * @param source indicates whether the results should be fetched from the cache
+ * only (`Source.cache`), the server only (`Source.server`), or to attempt
+ * the server and fall back to the cache (`Source.default`).
+ * @param completion a block to execute once the documents have been successfully read.
+ * documentSet will be `nil` only if error is `non-nil`.
+ */
+// clang-format off
+- (void)getDocumentsWithSource:(FIRFirestoreSource)source completion:(FIRQuerySnapshotBlock)completion
+ NS_SWIFT_NAME(getDocuments(source:completion:));
+// clang-format on
+
+/**
* Attaches a listener for QuerySnapshot events.
*
* @param listener The listener to attach.