aboutsummaryrefslogtreecommitdiff
path: root/src/fields/KVPField.ts
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-03-09 16:06:18 -0500
committerab <abdullah_ahmed@brown.edu>2019-03-09 16:06:18 -0500
commita2b90031fe06701b0ecc7c6fa3b48c933e4d37b8 (patch)
tree541052a97652ad25b0829685f205ec35d3976743 /src/fields/KVPField.ts
parentb72ff1323bc76dc244ebe50893aa78064fd836c7 (diff)
parent09928503be98d605052fba65dcd2f91f9b056f23 (diff)
fix
Diffstat (limited to 'src/fields/KVPField.ts')
-rw-r--r--src/fields/KVPField.ts30
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