diff options
author | laurawilsonri <laura_wilson@brown.edu> | 2019-03-18 18:14:27 -0400 |
---|---|---|
committer | laurawilsonri <laura_wilson@brown.edu> | 2019-03-18 18:14:27 -0400 |
commit | 9d939c1190ef86e456cf26e9f5cb84743279f7a6 (patch) | |
tree | 24d72d918f2becf6762ea30b92da7339957eedbd /src/server/database.ts | |
parent | 67170e521366f8178645cc85aaf377e53b1a6f21 (diff) | |
parent | f70ad315167b714f11f7d68f35a46abe9e525a4d (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into editableSchema
Diffstat (limited to 'src/server/database.ts')
-rw-r--r-- | src/server/database.ts | 10 |
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); }) }; |