X-Git-Url: https://git.xangelo.ca/?p=rss-reader.git;a=blobdiff_plain;f=src%2Flib%2Fdb.ts;fp=src%2Flib%2Fdb.ts;h=0d89478130a8b7eefa48dd07b6f1e7e02d3d9a56;hp=79de4ef0247ae1d336d4392009b8787c3cabcdeb;hb=e9df66eb3ec232afc5595cf25cbeef2391cc003b;hpb=ec6bf9840b03bdab70c4ca028b6e0acc7c4af897 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) + } + } };