@@ -26,7 +26,20 @@ export interface DocumentOptions {
26
26
hasLocalMutations : boolean ;
27
27
}
28
28
29
- export class Document {
29
+ /**
30
+ * The result of a lookup for a given path may be an existing document or a
31
+ * marker that this document does not exist at a given version.
32
+ */
33
+ export abstract class MaybeDocument {
34
+ readonly key : DocumentKey ;
35
+ readonly version : SnapshotVersion ;
36
+ }
37
+
38
+ /**
39
+ * Represents a document in Firestore with a key, version, data and whether the
40
+ * data has local mutations applied to it.
41
+ */
42
+ export class Document implements MaybeDocument {
30
43
readonly hasLocalMutations : boolean ;
31
44
32
45
constructor (
@@ -68,7 +81,7 @@ export class Document {
68
81
) ;
69
82
}
70
83
71
- static compareByKey ( d1 : MaybeDocument , d2 : MaybeDocument ) : number {
84
+ static compareByKey ( d1 : Document , d2 : Document ) : number {
72
85
return DocumentKey . comparator ( d1 . key , d2 . key ) ;
73
86
}
74
87
@@ -88,7 +101,7 @@ export class Document {
88
101
* Version is set to 0 if we don't point to any specific time, otherwise it
89
102
* denotes time we know it didn't exist at.
90
103
*/
91
- export class NoDocument {
104
+ export class NoDocument implements MaybeDocument {
92
105
constructor ( readonly key : DocumentKey , readonly version : SnapshotVersion ) { }
93
106
94
107
toString ( ) : string {
@@ -102,14 +115,4 @@ export class NoDocument {
102
115
other . key . isEqual ( this . key )
103
116
) ;
104
117
}
105
-
106
- static compareByKey ( d1 : MaybeDocument , d2 : MaybeDocument ) : number {
107
- return DocumentKey . comparator ( d1 . key , d2 . key ) ;
108
- }
109
118
}
110
-
111
- /**
112
- * A union type representing either a full document or a deleted document.
113
- * The NoDocument is used when it doesn't exist on the server.
114
- */
115
- export type MaybeDocument = Document | NoDocument ;
0 commit comments