From: xangelo Date: Wed, 6 Apr 2022 16:49:33 +0000 (-0400) Subject: add new queries to get unread counts, read all items, delete feed X-Git-Url: https://git.xangelo.ca/?p=rss-reader.git;a=commitdiff_plain;h=e9df66eb3ec232afc5595cf25cbeef2391cc003b add new queries to get unread counts, read all items, delete feed --- 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) + } + } };