'Firestore SnapshotOptions = { serverTimestamps: 'previous' }, what value it return if there is no previous value?
export declare interface SnapshotOptions {
/**
* If set, controls the return value for server timestamps that have not yet
* been set to their final value.
*
* By specifying 'estimate', pending server timestamps return an estimate
* based on the local clock. This estimate will differ from the final value
* and cause these values to change once the server result becomes available.
*
* By specifying 'previous', pending timestamps will be ignored and return
* their previous value instead.
*
* If omitted or set to 'none', `null` will be returned by default until the
* server value becomes available.
*/
readonly serverTimestamps?: 'estimate' | 'previous' | 'none';
}
It stated there that previous returns the previous timestamp when pending, what if this is the first time it is written into the database and no previous value?
what will it return?
Solution 1:[1]
If you use previous without any timestamps being available in the server already than this timestamp will be treated as an "unresolved timestamp" and you get the a null returned value, therefore same behavior as having it omitted or set to none.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ralemos |
