From 91a50451776fd55aa4bac888de1f1e5248867a18 Mon Sep 17 00:00:00 2001 From: pikokr Date: Wed, 19 Apr 2023 21:47:40 +0900 Subject: [PATCH] feat: delete option for regex checker --- bot/findInvalidRules.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bot/findInvalidRules.mjs b/bot/findInvalidRules.mjs index 2eeb19c5..e845c509 100644 --- a/bot/findInvalidRules.mjs +++ b/bot/findInvalidRules.mjs @@ -5,6 +5,8 @@ config({ path: '../shared/.env' }) import { PrismaClient } from '@prisma/client' +const argv = process.argv + const db = new PrismaClient() const ruleElements = await db.ruleElement.findMany() @@ -17,5 +19,9 @@ for (const el of ruleElements) { console.error(e.message) console.error('element:', el) console.error('rule:', await db.rule.findUnique({where: {id: el.ruleId}})) + + if (argv.includes('--delete')) { + await db.ruleElement.delete({ where: { id: el.id } }) + } } }