diff options
author | Mohammad Amoush <mohammad_amoush@brown.edu> | 2019-07-22 13:57:10 -0400 |
---|---|---|
committer | Mohammad Amoush <mohammad_amoush@brown.edu> | 2019-07-22 13:57:10 -0400 |
commit | 658ded478c273654174cd2706f8b3e021b8ceb95 (patch) | |
tree | 7526f7850dd3702b9746125d2f4349a0d6aea8ee /src/server/database.ts | |
parent | 157060f7e6029c76765aa20d8fdbe325401a3880 (diff) | |
parent | 8db50c6ba0be83b85c896043da53e40c17523e90 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into youtube-api-muhammed
Diffstat (limited to 'src/server/database.ts')
-rw-r--r-- | src/server/database.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/server/database.ts b/src/server/database.ts index 29a8ffafa..7f5331998 100644 --- a/src/server/database.ts +++ b/src/server/database.ts @@ -140,6 +140,17 @@ export class Database { } } + public updateMany(query: any, update: any, collectionName = "newDocuments") { + if (this.db) { + const db = this.db; + return new Promise<mongodb.WriteOpResult>(res => db.collection(collectionName).update(query, update, (_, result) => res(result))); + } else { + return new Promise<mongodb.WriteOpResult>(res => { + this.onConnect.push(() => this.updateMany(query, update, collectionName).then(res)); + }); + } + } + public print() { console.log("db says hi!"); } |