aboutsummaryrefslogtreecommitdiff
path: root/src/server/database.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/database.ts')
-rw-r--r--src/server/database.ts27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/server/database.ts b/src/server/database.ts
index 99b13805e..616251c72 100644
--- a/src/server/database.ts
+++ b/src/server/database.ts
@@ -1,8 +1,4 @@
-import { action, configure } from 'mobx';
import * as mongodb from 'mongodb';
-import { ObjectID } from 'mongodb';
-import { Transferable } from './Message';
-import { Utils } from '../Utils';
export class Database {
public static Instance = new Database()
@@ -21,7 +17,16 @@ export class Database {
let collection = this.db.collection('documents');
collection.updateOne({ _id: id }, { $set: value }, {
upsert: true
- }, callback);
+ }, (err, res) => {
+ if (err) {
+ console.log(err.message);
+ console.log(err.errmsg);
+ }
+ // if (res) {
+ // console.log(JSON.stringify(res.result));
+ // }
+ callback()
+ });
}
}
@@ -32,11 +37,13 @@ export class Database {
}
}
- public deleteAll(collectionName: string = 'documents') {
- if (this.db) {
- let collection = this.db.collection(collectionName);
- collection.deleteMany({});
- }
+ public deleteAll(collectionName: string = 'documents'): Promise<any> {
+ return new Promise(res => {
+ if (this.db) {
+ let collection = this.db.collection(collectionName);
+ collection.deleteMany({}, res);
+ }
+ })
}
public insert(kvpairs: any) {