feat: migrate to bun runtime and update dependencies
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import Database from "better-sqlite3";
|
||||
import { Database } from "bun:sqlite";
|
||||
import path from "path";
|
||||
|
||||
const dbPath = path.join(__dirname, "../data/podcast.db");
|
||||
@ -28,17 +28,26 @@ export interface Episode {
|
||||
sourceLink: string;
|
||||
}
|
||||
|
||||
export async function markAsProcessed(feedUrl: string, itemId: string): Promise<boolean> {
|
||||
const stmt = db.prepare("SELECT 1 FROM processed_feed_items WHERE feed_url = ? AND item_id = ?");
|
||||
export async function markAsProcessed(
|
||||
feedUrl: string,
|
||||
itemId: string,
|
||||
): Promise<boolean> {
|
||||
const stmt = db.prepare(
|
||||
"SELECT 1 FROM processed_feed_items WHERE feed_url = ? AND item_id = ?",
|
||||
);
|
||||
const row = stmt.get(feedUrl, itemId);
|
||||
if (row) return true;
|
||||
const insert = db.prepare("INSERT INTO processed_feed_items (feed_url, item_id, processed_at) VALUES (?, ?, ?)");
|
||||
const insert = db.prepare(
|
||||
"INSERT INTO processed_feed_items (feed_url, item_id, processed_at) VALUES (?, ?, ?)",
|
||||
);
|
||||
insert.run(feedUrl, itemId, new Date().toISOString());
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function saveEpisode(ep: Episode): Promise<void> {
|
||||
const stmt = db.prepare("INSERT OR IGNORE INTO episodes (id, title, pubDate, audioPath, sourceLink) VALUES (?, ?, ?, ?, ?)");
|
||||
const stmt = db.prepare(
|
||||
"INSERT OR IGNORE INTO episodes (id, title, pubDate, audioPath, sourceLink) VALUES (?, ?, ?, ?, ?)",
|
||||
);
|
||||
stmt.run(ep.id, ep.title, ep.pubDate, ep.audioPath, ep.sourceLink);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user