From dd343656cbc52337b8f31d0f05882f4848c1d4d6 Mon Sep 17 00:00:00 2001 From: apt-get Date: Sat, 24 May 2025 16:24:05 +0200 Subject: [PATCH] update db management scripts to bun --- db/init_db.js | 2 +- db/update_db.js | 4 ++-- package.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/init_db.js b/db/init_db.js index 2534185..14d4ce2 100644 --- a/db/init_db.js +++ b/db/init_db.js @@ -1,5 +1,5 @@ import fs from 'fs'; -import Database from 'better-sqlite3'; +import { Database } from 'bun:sqlite'; const dbName = 'strimserve.db'; diff --git a/db/update_db.js b/db/update_db.js index 99ee4f3..823ba0b 100644 --- a/db/update_db.js +++ b/db/update_db.js @@ -1,6 +1,6 @@ import fs from 'fs'; import path from 'path'; -import Database from 'better-sqlite3'; +import { Database } from 'bun:sqlite'; import dotenv from 'dotenv'; dotenv.config({ path: '../.env' }); @@ -23,7 +23,7 @@ const lookup = { }; // Retrieve existing IDs from Stream -const existingIds = db.prepare('SELECT id FROM Stream').pluck().all(); +const existingIds = db.prepare('SELECT id FROM Stream').all().map(row => row.id); // Create a set of existing IDs for efficient lookup const idSet = new Set(existingIds); diff --git a/package.json b/package.json index 6414242..1f67ae6 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --check . && eslint .", "format": "prettier --write .", - "init_db": "cd db && node ./init_db.js", - "update_db": "cd db && node ./update_db.js", + "init_db": "cd db && bun --bun ./init_db.js", + "update_db": "cd db && bun --bun ./update_db.js", "generate_iconfont_subset": "cd scripts && bash ./generate_iconfont_subset.sh" }, "dependencies": {