Skip to content

Commit c32a9a6

Browse files
Protobuf-backed FieldValues (#2682)
1 parent 251a980 commit c32a9a6

File tree

9 files changed

+780
-127
lines changed

9 files changed

+780
-127
lines changed

packages/firestore/src/model/field_value.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class FieldValueOptions {
111111
* Potential types returned by FieldValue.value(). This could be stricter
112112
* (instead of using {}), but there's little benefit.
113113
*
114-
* Note that currently we use AnyJs (which is identical except includes
114+
* Note that currently we use `unknown` (which is identical except includes
115115
* undefined) for incoming user data as a convenience to the calling code (but
116116
* we'll throw if the data contains undefined). This should probably be changed
117117
* to use FieldType, but all consuming code will have to be updated to
@@ -367,6 +367,9 @@ export class TimestampValue extends FieldValue {
367367
* localWriteTime.
368368
*/
369369
export class ServerTimestampValue extends FieldValue {
370+
// TODO(mrschmidt): Represent ServerTimestamps as a PrimitiveType with a
371+
// Map containing a private `__type__` field (or similar).
372+
370373
typeOrder = TypeOrder.TimestampValue;
371374

372375
constructor(
@@ -402,7 +405,7 @@ export class ServerTimestampValue extends FieldValue {
402405
compareTo(other: FieldValue): number {
403406
if (other instanceof ServerTimestampValue) {
404407
return this.localWriteTime._compareTo(other.localWriteTime);
405-
} else if (other instanceof TimestampValue) {
408+
} else if (other.typeOrder === TypeOrder.TimestampValue) {
406409
// Server timestamps come after all concrete timestamps.
407410
return 1;
408411
} else {

0 commit comments

Comments
 (0)