aboutsummaryrefslogtreecommitdiff
path: root/src/server/updateSearch.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-12-10 21:08:39 -0500
committerSam Wilkins <samwilkins333@gmail.com>2019-12-10 21:08:39 -0500
commit4ed6fd76752d60c617d9a396193ab6d8195dac1c (patch)
tree89d734280ecd548fcc5af16cfe39d061298dead1 /src/server/updateSearch.ts
parentc17b200f6d0cb136851b798f280aba9b3862c337 (diff)
persistence daemon improvement, relaxed dummy gmail account security to allow messages
Diffstat (limited to 'src/server/updateSearch.ts')
-rw-r--r--src/server/updateSearch.ts13
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);
}