FIRFirestoreSource.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. typedef NS_ENUM(NSUInteger, FIRFirestoreSource) {
  25. /**
  26. * Causes Firestore to try to retrieve an up-to-date (server-retrieved)
  27. * snapshot, but fall back to returning cached data if the server can't be
  28. * reached.
  29. */
  30. FIRFirestoreSourceDefault,
  31. /**
  32. * Causes Firestore to avoid the cache, generating an error if the server
  33. * cannot be reached. Note that the cache will still be updated if the
  34. * server request succeeds. Also note that latency-compensation still takes
  35. * effect, so any pending write operations will be visible in the returned
  36. * data (merged into the server-provided data).
  37. */
  38. FIRFirestoreSourceServer,
  39. /**
  40. * Causes Firestore to immediately return a value from the cache, ignoring
  41. * the server completely (implying that the returned value may be stale with
  42. * respect to the value on the server). If there is no data in the cache to
  43. * satisfy the `getDocument[s]` call, `DocumentReference.getDocument()` will
  44. * return an error and `QuerySnapshot.getDocuments()` will return an empty
  45. * `QuerySnapshot` with no documents.
  46. */
  47. FIRFirestoreSourceCache
  48. } NS_SWIFT_NAME(FirestoreSource);