diff options
| author | Sam Wilkins <samwilkins333@gmail.com> | 2019-12-13 14:25:45 -0500 |
|---|---|---|
| committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-12-13 14:25:45 -0500 |
| commit | 529c9dbe42ab8f732bd8a244246eb1b94c3b5053 (patch) | |
| tree | 13110af32830b25fca4eed583c6f23cee7ecd0ee /src/server/updateSearch.ts | |
| parent | a2d2737fa4ec1a57f5288ed72eb44a2be4588ee8 (diff) | |
| parent | 9a90830162cf176b58729385588accf3b589454d (diff) | |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/server/updateSearch.ts')
| -rw-r--r-- | src/server/updateSearch.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/server/updateSearch.ts b/src/server/updateSearch.ts index 5ae6885c5..83094d36a 100644 --- a/src/server/updateSearch.ts +++ b/src/server/updateSearch.ts @@ -59,7 +59,14 @@ async function update() { }); const cursor = await log_execution({ startMessage: "Connecting to and querying for all documents from database...", - endMessage: "Connection successful and query complete", + endMessage: ({ result, error }) => { + const success = error === null && result !== undefined; + if (!success) { + console.log(red("Unable to connect to the database.")); + process.exit(0); + } + return "Connection successful and query complete"; + }, action: () => Database.Instance.query({}), color: yellow }); @@ -92,7 +99,7 @@ async function update() { updates.push(update); } } - await cursor.forEach(updateDoc); + await cursor?.forEach(updateDoc); const result = await log_execution({ startMessage: `Dispatching updates for ${updates.length} documents`, endMessage: "Dispatched updates complete", @@ -107,7 +114,7 @@ async function update() { console.log(result); console.log("\n"); } - await cursor.close(); + await cursor?.close(); process.exit(0); } |
