aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormadelinegr <laura_wilson@brown.edu>2019-02-13 17:40:08 -0500
committermadelinegr <laura_wilson@brown.edu>2019-02-13 17:40:08 -0500
commitbb3ebfa2e3176fdfb648cb7da052e07989fee050 (patch)
tree95bca297ca99f9bacc4512c44ab573ef5ce7bdae /src
parent430878f6dd8d36b1322e15d0898ada0d44fecacb (diff)
broke even
Diffstat (limited to 'src')
-rw-r--r--src/fields/Document.ts2
-rw-r--r--src/fields/DocumentReference.ts4
-rw-r--r--src/fields/Field.ts2
-rw-r--r--src/fields/ImageField.ts4
-rw-r--r--src/fields/Key.ts4
-rw-r--r--src/fields/ListField.ts4
-rw-r--r--src/fields/NumberField.ts4
-rw-r--r--src/fields/RichTextField.ts4
-rw-r--r--src/fields/TextField.ts4
-rw-r--r--src/server/Message.ts27
-rw-r--r--src/server/database.ts6
-rw-r--r--src/server/index.ts4
12 files changed, 34 insertions, 35 deletions
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index 56ac3c471..f7239145f 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -159,7 +159,7 @@ export class Document extends Field {
throw new Error("Method not implemented.");
}
- ToJson(): { type: Types, data: [string, string][], _id: ObjectID } {
+ ToJson(): { type: Types, data: [string, string][], _id: String } {
let fields: [string, string][] = []
this._proxies.forEach((field, key) => {
if (field) {
diff --git a/src/fields/DocumentReference.ts b/src/fields/DocumentReference.ts
index b3d8e059d..c9313a73e 100644
--- a/src/fields/DocumentReference.ts
+++ b/src/fields/DocumentReference.ts
@@ -43,11 +43,11 @@ export class DocumentReference extends Field {
return "";
}
- ToJson(): { type: Types, data: FIELD_ID, _id: ObjectID } {
+ ToJson(): { type: Types, data: FIELD_ID, _id: String } {
return {
type: Types.DocumentReference,
data: this.document.Id,
- _id: new ObjectID(this.Id)
+ _id: this.Id
}
}
} \ No newline at end of file
diff --git a/src/fields/Field.ts b/src/fields/Field.ts
index 4b9d996ac..16569e175 100644
--- a/src/fields/Field.ts
+++ b/src/fields/Field.ts
@@ -65,5 +65,5 @@ export abstract class Field {
abstract Copy(): Field;
- abstract ToJson(): { _id: ObjectID, type: Types, data: any }
+ abstract ToJson(): { _id: String, type: Types, data: any }
} \ No newline at end of file
diff --git a/src/fields/ImageField.ts b/src/fields/ImageField.ts
index 30fe0970b..39eed9398 100644
--- a/src/fields/ImageField.ts
+++ b/src/fields/ImageField.ts
@@ -20,11 +20,11 @@ export class ImageField extends BasicField<URL> {
return new ImageField(this.Data);
}
- ToJson(): { type: Types, data: URL, _id: ObjectID } {
+ ToJson(): { type: Types, data: URL, _id: String } {
return {
type: Types.Image,
data: this.Data,
- _id: new ObjectID(this.Id)
+ _id: this.Id
}
}
} \ No newline at end of file
diff --git a/src/fields/Key.ts b/src/fields/Key.ts
index ffcbfc8b4..7120c6e3e 100644
--- a/src/fields/Key.ts
+++ b/src/fields/Key.ts
@@ -33,11 +33,11 @@ export class Key extends Field {
return name;
}
- ToJson(): { type: Types, data: string, _id: ObjectID } {
+ ToJson(): { type: Types, data: string, _id: String } {
return {
type: Types.Key,
data: this.name,
- _id: new ObjectID(this.Id)
+ _id: this.Id
}
}
}
diff --git a/src/fields/ListField.ts b/src/fields/ListField.ts
index e98ced902..9a26cb142 100644
--- a/src/fields/ListField.ts
+++ b/src/fields/ListField.ts
@@ -16,11 +16,11 @@ export class ListField<T extends Field> extends BasicField<T[]> {
return new ListField<T>(this.Data);
}
- ToJson(): { type: Types, data: T[], _id: ObjectId } {
+ ToJson(): { type: Types, data: T[], _id: String } {
return {
type: Types.List,
data: this.Data,
- _id: new ObjectId(this.Id)
+ _id: this.Id
}
}
} \ No newline at end of file
diff --git a/src/fields/NumberField.ts b/src/fields/NumberField.ts
index ce07a18b8..f31be0c25 100644
--- a/src/fields/NumberField.ts
+++ b/src/fields/NumberField.ts
@@ -16,9 +16,9 @@ export class NumberField extends BasicField<number> {
return new NumberField(this.Data);
}
- ToJson(): { _id: ObjectID, type: Types, data: number } {
+ ToJson(): { _id: String, type: Types, data: number } {
return {
- _id: new ObjectID(this.Id),
+ _id: this.Id,
type: Types.Number,
data: this.Data
}
diff --git a/src/fields/RichTextField.ts b/src/fields/RichTextField.ts
index a7ea1f2ce..2ed4d11f8 100644
--- a/src/fields/RichTextField.ts
+++ b/src/fields/RichTextField.ts
@@ -16,11 +16,11 @@ export class RichTextField extends BasicField<string> {
return new RichTextField(this.Data);
}
- ToJson(): { type: Types, data: string, _id: ObjectID } {
+ ToJson(): { type: Types, data: string, _id: String } {
return {
type: Types.RichText,
data: this.Data,
- _id: new ObjectID(this.Id)
+ _id: this.Id
}
}
diff --git a/src/fields/TextField.ts b/src/fields/TextField.ts
index 692b746d1..545aa8c35 100644
--- a/src/fields/TextField.ts
+++ b/src/fields/TextField.ts
@@ -16,11 +16,11 @@ export class TextField extends BasicField<string> {
return new TextField(this.Data);
}
- ToJson(): { type: Types, data: string, _id: ObjectID } {
+ ToJson(): { type: Types, data: string, _id: String } {
return {
type: Types.Text,
data: this.Data,
- _id: new ObjectID(this.Id)
+ _id: this.Id
}
}
}
diff --git a/src/server/Message.ts b/src/server/Message.ts
index 0391b6671..658c5612b 100644
--- a/src/server/Message.ts
+++ b/src/server/Message.ts
@@ -1,6 +1,5 @@
import { Utils } from "../Utils";
import { FIELD_ID, Field } from "../fields/Field";
-import { ObjectId } from "bson";
export class Message<T> {
private name: string;
@@ -52,9 +51,9 @@ export enum Types {
export class DocumentTransfer implements Transferable {
readonly type = Types.Document
- _id: ObjectId;
+ _id: String;
- constructor(readonly obj: { type: Types, data: [string, string][], _id: ObjectId }) {
+ constructor(readonly obj: { type: Types, data: [string, string][], _id: String }) {
this._id = obj._id
}
}
@@ -62,56 +61,56 @@ export class DocumentTransfer implements Transferable {
export class ImageTransfer implements Transferable {
readonly type = Types.Image
- constructor(readonly _id: ObjectId) { }
+ constructor(readonly _id: String) { }
}
export class KeyTransfer implements Transferable {
name: string
- readonly _id: ObjectId
+ readonly _id: String
readonly type = Types.Key
constructor(i: string, n: string) {
this.name = n
- this._id = new ObjectId(i)
+ this._id = i
}
}
export class ListTransfer implements Transferable {
type = Types.List;
- constructor(readonly _id: ObjectId) { }
+ constructor(readonly _id: String) { }
}
export class NumberTransfer implements Transferable {
readonly type = Types.Number
- constructor(readonly value: number, readonly _id: ObjectId) { }
+ constructor(readonly value: number, readonly _id: String) { }
}
export class TextTransfer implements Transferable {
value: string
- readonly _id: ObjectId
+ readonly _id: String
readonly type = Types.Text
constructor(t: string, i: string) {
this.value = t
- this._id = new ObjectId(i)
+ this._id = i
}
}
export class RichTextTransfer implements Transferable {
value: string
- readonly _id: ObjectId
+ readonly _id: String
readonly type = Types.Text
constructor(t: string, i: string) {
this.value = t
- this._id = new ObjectId(i)
+ this._id = i
}
}
export interface Transferable {
- readonly _id: ObjectId
+ readonly _id: String
readonly type: Types
}
@@ -119,6 +118,6 @@ export namespace MessageStore {
export const Foo = new Message<string>("Foo");
export const Bar = new Message<string>("Bar");
export const AddDocument = new Message<DocumentTransfer>("Add Document");
- export const SetField = new Message<{ _id: ObjectId, data: any, type: Types }>("Set Field")
+ export const SetField = new Message<{ _id: String, data: any, type: Types }>("Set Field")
export const GetField = new Message<GetFieldArgs>("Get Field")
} \ No newline at end of file
diff --git a/src/server/database.ts b/src/server/database.ts
index 72ddbc82c..16211a2f6 100644
--- a/src/server/database.ts
+++ b/src/server/database.ts
@@ -9,7 +9,7 @@ export class Database {
private MongoClient = mongodb.MongoClient;
private url = 'mongodb://localhost:27017/Dash';
- public update(id: mongodb.ObjectID, value: any) {
+ public update(id: String, value: any) {
this.MongoClient.connect(this.url, (err, db) => {
let collection = db.db().collection('documents');
collection.update({ _id: id }, { $set: value });
@@ -33,7 +33,7 @@ export class Database {
});
}
- public getDocument(id: mongodb.ObjectID): string | undefined {
+ public getDocument(id: String): string | undefined {
var result: JSON;
this.MongoClient.connect(this.url, (err, db) => {
if (err) {
@@ -41,7 +41,7 @@ export class Database {
return undefined
}
let collection = db.db().collection('documents');
- collection.findOne({ _id: Utils.GenerateDeterministicGuid(id.toHexString()) }, (err: any, res: any) => result = res)
+ collection.findOne({ _id: id }, (err: any, res: any) => result = res)
console.log(result)
db.close();
if (!result) {
diff --git a/src/server/index.ts b/src/server/index.ts
index 98d897d2f..ff3e2a5eb 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -76,8 +76,8 @@ function setField(newValue: Transferable) {
}
function getField([fieldRequest, callback]: [GetFieldArgs, (field: Field) => void]) {
- let fieldid: string = fieldRequest.field
- let result: string | undefined = Database.Instance.getDocument(new ObjectID(fieldid))
+ let fieldId: string = fieldRequest.field
+ let result: string | undefined = Database.Instance.getDocument(fieldId)
if (result) {
let fromJson: Field = ServerUtils.FromJson(result)
}