diff options
author | ab <abdullah_ahmed@brown.edu> | 2019-03-09 16:06:18 -0500 |
---|---|---|
committer | ab <abdullah_ahmed@brown.edu> | 2019-03-09 16:06:18 -0500 |
commit | a2b90031fe06701b0ecc7c6fa3b48c933e4d37b8 (patch) | |
tree | 541052a97652ad25b0829685f205ec35d3976743 /src/fields/KVPField.ts | |
parent | b72ff1323bc76dc244ebe50893aa78064fd836c7 (diff) | |
parent | 09928503be98d605052fba65dcd2f91f9b056f23 (diff) |
fix
Diffstat (limited to 'src/fields/KVPField.ts')
-rw-r--r-- | src/fields/KVPField.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/fields/KVPField.ts b/src/fields/KVPField.ts new file mode 100644 index 000000000..a7ecc0768 --- /dev/null +++ b/src/fields/KVPField.ts @@ -0,0 +1,30 @@ +import { BasicField } from "./BasicField" +import { FieldId } from "./Field"; +import { Types } from "../server/Message"; +import { Document } from "./Document" + +export class KVPField extends BasicField<Document> { + constructor(data: Document | undefined = undefined, id?: FieldId, save: boolean = true) { + super(data == undefined ? new Document() : data, save, id); + } + + toString(): string { + return this.Data.Title; + } + + ToScriptString(): string { + return `new KVPField("${this.Data}")`; + } + + Copy() { + return new KVPField(this.Data); + } + + ToJson(): { type: Types, data: Document, _id: string } { + return { + type: Types.Text, + data: this.Data, + _id: this.Id + } + } +}
\ No newline at end of file |