From e9df66eb3ec232afc5595cf25cbeef2391cc003b Mon Sep 17 00:00:00 2001 From: xangelo Date: Wed, 6 Apr 2022 12:49:33 -0400 Subject: [PATCH] add new queries to get unread counts, read all items, delete feed --- src/lib/db.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/db.ts b/src/lib/db.ts index 79de4ef..0d89478 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -18,5 +18,14 @@ export const query = { addFeedItem: writer.prepare('insert into feed_items (id, feed_id, guid, title, link, pub_date, content) values (?, ?, ?, ?, ?, ?, ?)'), getFeedsFor: reader.prepare('select id, feed_id, guid, title, link, pub_date,read_at from feed_items where feed_id = ? and pub_date > ? order by pub_date desc'), readItem: writer.prepare('update feed_items set read_at = ? where id = ? and read_at = 0'), - getUnreadCountForAll: reader.prepare('select count(id) as unread, feed_id from feed_items where read_at = 0 group by feed_id') + getUnreadCountForAll: reader.prepare('select count(id) as unread, feed_id from feed_items where read_at = 0 group by feed_id'), + readAllItems: writer.prepare(`update feed_items set read_at = datetime('now') where feed_id = ?`), + _deleteFeedItems: writer.prepare(`delete from feed_items where feed_id = ?`), + _deleteFeed: writer.prepare(`delete from feedlist where id = ?`), + deleteFeed: { + run: (feed_id: string) => { + query._deleteFeedItems.run(feed_id); + query._deleteFeed.run(feed_id) + } + } }; -- 2.25.1