blob: 9d3c209b4c1fb3bc66828331aaf69b8187e24ad0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import { Field, Opt, FieldValue, FieldId } from "./Field";
import { Document } from "./Document";
import { Key } from "./Key";
import { Types } from "../server/Message";
import { ObjectID } from "bson";
export class DocumentReference extends Field {
get Key(): Key {
return this.key;
}
get Document(): Document {
return this.document;
}
constructor(private document: Document, private key: Key) {
super();
}
UpdateFromServer() {
}
Dereference(): FieldValue<Field> {
return this.document.Get(this.key);
}
DereferenceToRoot(): FieldValue<Field> {
let field: FieldValue<Field> = this;
while (field instanceof DocumentReference) {
field = field.Dereference();
}
return field;
}
TrySetValue(value: any): boolean {
throw new Error("Method not implemented.");
}
GetValue() {
throw new Error("Method not implemented.");
}
Copy(): Field {
throw new Error("Method not implemented.");
}
ToScriptString(): string {
return "";
}
ToJson(): { type: Types, data: FieldId, _id: string } {
return {
type: Types.DocumentReference,
data: this.document.Id,
_id: this.Id
}
}
}
|