Scripting

This commit is contained in:
zkldi
2021-04-18 00:54:10 +01:00
parent aa44991490
commit f0b79b67c5
2 changed files with 26 additions and 12 deletions
+22
View File
@@ -0,0 +1,22 @@
import db from "../db/db";
import CreateLogCtx from "../logger";
const logger = CreateLogCtx("scripts/initialise-counters.ts");
(async () => {
let users = await db.counters.findOne({
counterName: "users",
});
if (users) {
throw new Error(`"users" document already exists, exiting.`);
}
await db.counters.insert({
counterName: "users",
value: 0,
});
logger.info("Successfully initialised counter documents. Exiting.");
process.exit(0);
})();