aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-04-23 19:00:15 -0400
committerab <abdullah_ahmed@brown.edu>2019-04-23 19:00:15 -0400
commit85ce4c9a3cd665983067d7783e20eb7701376503 (patch)
tree3179a600dccbb75f49bfe2dc97832d484661db17
parent94fa065ae2a0f3ccb6a16141a45f11543add3b63 (diff)
idk
-rw-r--r--src/server/index.ts28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/server/index.ts b/src/server/index.ts
index b3df90199..464d3f68f 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -35,6 +35,7 @@ import flash = require('connect-flash');
import c = require("crypto");
import { Search } from './Search';
import { debug } from 'util';
+import _ = require('lodash');
const MongoStore = require('connect-mongo')(session);
const mongoose = require('mongoose');
@@ -289,11 +290,32 @@ function UpdateField(socket: Socket, diff: Diff) {
Database.Instance.update(diff.id, diff.diff,
() => socket.broadcast.emit(MessageStore.UpdateField.Message, diff), false, "newDocuments");
//if (diff.diff === Types.Text) {
- Search.Instance.updateDocument({ name: "john", burns: "true" });
- Search.Instance.updateDocument({ id: diff.id, data: diff.diff.data });
+ //Search.Instance.updateDocument({ name: "john", burns: "true" });
+ //Search.Instance.updateDocument({ id: diff.id, data: diff.diff.data });
//console.log("set field");
//}
- console.log("updated field", diff.diff);
+ const docid = { id: diff.id };
+ const docfield = diff.diff;
+ console.log("FIELD: ", docfield);
+ var dynfield = false;
+ for (var key in docfield) {
+ const val = docfield[key];
+ if (typeof val === 'number') {
+ key = key + "_n";
+ dynfield = true;
+ }
+ else if (typeof val === 'string') {
+ key = key + "_t";
+ dynfield = true;
+ }
+ console.log(key);
+ }
+ var merged = {};
+ _.extend(merged, docid, docfield);
+ if (dynfield) {
+ console.log("dynamic field detected!");
+ Search.Instance.updateDocument(merged);
+ }
}
function CreateField(newValue: any) {