Skip to content

Commit

Permalink
refactor: cleanup db:reset script (denoland#509)
Browse files Browse the repository at this point in the history
This cleans up some of the unnecessary LOC for the script.

Related to denoland#471
  • Loading branch information
iuioiua authored Sep 5, 2023
1 parent b7af728 commit b471ec7
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions tasks/db_reset.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
// Copyright 2023 the Deno authors. All rights reserved. MIT license.
import { kv } from "@/utils/db.ts";

export async function resetKv() {
const iter = kv.list({ prefix: [] });
const promises = [];
for await (const res of iter) promises.push(kv.delete(res.key));
await Promise.all(promises);
}
if (!confirm("WARNING: The database will be reset. Continue?")) Deno.exit();

if (import.meta.main) {
if (
!confirm(
"This script deletes all data from the Deno KV database. Are you sure you'd like to continue?",
)
) {
close();
}
await resetKv();
await kv.close();
}
const iter = kv.list({ prefix: [] });
const promises = [];
for await (const res of iter) promises.push(kv.delete(res.key));
await Promise.all(promises);

kv.close();

0 comments on commit b471ec7

Please sign in to comment.