aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Message.ts27
-rw-r--r--src/server/database.ts6
-rw-r--r--src/server/index.ts4
3 files changed, 18 insertions, 19 deletions
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)
}