Global

Type Definitions

ContextOptions

Options for interacting with Firestore.
Properties:
Name Type Attributes Default Description
readOnly Boolean <optional>
false whether writes are allowed (we could allow writes outside of tx for performance too, but omitting it for safety for now)
consistentReads Boolean <optional>
true whether multiple reads are guaranteed to be from a consistent snapshot
retries Number <optional>
4 The number of times to retry after the initial attempt fails.
initialBackoff Number <optional>
500 In milliseconds, delay after the first attempt fails and before first retry happens.
maxBackoff Number <optional>
10000 In milliseconds, max delay between retries. Must be larger than 200.
cacheModels Number <optional>
false Whether to cache models already retrieved from the database. When off, getting a model with the same key the second time in the same transaction results in an error. When on, `get`ting the same key simply returns the cached model. Previous modifications done to the model are reflected in the returned model. If the model key was used in some API other than "get", an error will result.

FieldOptions

Properties:
Name Type Attributes Default Description
isKey Boolean <optional>
false If true, the field is a key. When specified, other options are forced to be { optional: false, immutable: true, default: undefined }. If user supplied values that conflicts with those values, InvalidOptionsError will be thrown.
optional Boolean <optional>
false If field can be left undefined.
immutable Boolean <optional>
false If field can be changed again after value is set to anything except undefined.
default * <optional>
Default value to use. IMPORTANT: Value is deeply copied, so additional modifications to the parameter will not reflect in the field.
schema schema <optional>
An optional JSON schema to validate Field's value.

GetParams

Parameters for fetching a model and options to control how a model is fetched from database.
Properties:
Name Type Attributes Default Description
createIfMissing Boolean <optional>
false If true, a model is returned regardless of whether the model exists on server. This behavior is the same as calling create when get(..., { createIfMissing: false }) returns undefined
* * <optional>
Besides the predefined options, custom key-value pairs can be added. These values will be made available to the Model's constructor as an argument.