An options object that configures the behavior ofget() calls onDocumentReference andQuery. By providing aGetOptions object, thesemethods can be configured to fetch results only from the server, only fromthe local cache or attempt to fetch results from the server and fall back tothe cache (which is the default).

Index

Properties

Properties

Optional source

source:"default" |"server" |"cache"

Describes whether we should get from server or cache.

Setting todefault (or not setting at all), causes Firestore to try toretrieve an up-to-date (server-retrieved) snapshot, but fall back toreturning cached data if the server can't be reached.

Setting toserver causes Firestore to avoid the cache, generating anerror if the server cannot be reached. Note that the cache will still beupdated if the server request succeeds. Also note that latency-compensationstill takes effect, so any pending write operations will be visible in thereturned data (merged into the server-provided data).

Setting tocache causes Firestore to immediately return a value from thecache, ignoring the server completely (implying that the returned valuemay be stale with respect to the value on the server.) If there is no datain the cache to satisfy theget() call,DocumentReference.get() willreturn an error andQuerySnapshot.get() will return an emptyQuerySnapshot with no documents.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2022-07-27 UTC.