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.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/server/database.ts b/src/server/database.ts
index f3c1c9427..99b13805e 100644
--- a/src/server/database.ts
+++ b/src/server/database.ts
@@ -19,7 +19,7 @@ export class Database {
public update(id: string, value: any, callback: () => void) {
if (this.db) {
let collection = this.db.collection('documents');
- collection.update({ _id: id }, { $set: value }, {
+ collection.updateOne({ _id: id }, { $set: value }, {
upsert: true
}, callback);
}
@@ -32,9 +32,9 @@ export class Database {
}
}
- public deleteAll() {
+ public deleteAll(collectionName: string = 'documents') {
if (this.db) {
- let collection = this.db.collection('documents');
+ let collection = this.db.collection(collectionName);
collection.deleteMany({});
}
}
@@ -70,6 +70,10 @@ export class Database {
let collection = this.db.collection('documents');
let cursor = collection.find({ _id: { "$in": ids } })
cursor.toArray((err, docs) => {
+ if (err) {
+ console.log(err.message);
+ console.log(err.errmsg);
+ }
fn(docs);
})
};