FIRFirestoreSource.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2018 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. /**
  18. * An enum that configures the behavior of `DocumentReference.getDocument()` and
  19. * `Query.getDocuments()`. By providing a source enum the `getDocument[s]`
  20. * methods can be configured to fetch results only from the server, only from
  21. * the local cache, or attempt to fetch results from the server and fall back to
  22. * the cache (which is the default).
  23. *
  24. * Setting the source to `Source.default` causes Firestore to try to retrieve an
  25. * up-to-date (server-retrieved) snapshot, but fall back to returning cached
  26. * data if the server can't be reached.
  27. *
  28. * Setting the source to `Source.server` causes Firestore to avoid the cache,
  29. * generating an error if the server cannot be reached. Note that the cache will
  30. * still be updated if the server request succeeds. Also note that
  31. * latency-compensation still takes effect, so any pending write operations will
  32. * be visible in the returned data (merged into the server-provided data).
  33. *
  34. * Setting the source to `Source.cache` causes Firestore to immediately return a
  35. * value from the cache, ignoring the server completely (implying that the
  36. * returned value may be stale with respect to the value on the server). If
  37. * there is no data in the cache to satisfy the `getDocument[s]` call,
  38. * `DocumentReference.getDocument()` will return an error and
  39. * `QuerySnapshot.getDocuments()` will return an empty `QuerySnapshot` with no
  40. * documents.
  41. */
  42. typedef NS_ENUM(NSUInteger, FIRFirestoreSource) {
  43. FIRFirestoreSourceDefault,
  44. FIRFirestoreSourceServer,
  45. FIRFirestoreSourceCache
  46. } NS_SWIFT_NAME(FirestoreSource);