+ _: {
+ createAccount: writer.prepare('insert into accounts (id, email, signup_date) values (?, ?, ?)'),
+ createLoginCode: writer.prepare('update accounts set login_code = ?, login_code_expires = ? where id = ?'),
+ isValidLoginCode: reader.prepare('select * from accounts where id = ? and login_code = ?'),
+ getAccountByEmail: reader.prepare('select * from accounts where email = ?'),
+ addFeed: writer.prepare('insert into feedlist (id, title, link, account_id) values (?, ?, ?, ?)'),
+ getFeed: reader.prepare('select * from feedlist where account_id = ? and id = ?'),
+ getFeedList: reader.prepare('select * from feedlist where account_id = ?'),
+ ingest_getFeedList: reader.prepare('select * from feedlist'),
+ getUnreadCountForAll: reader.prepare('select count(fi.id) as unread, feed_id, fl.title from feed_items fi join feedlist fl on fl.id = feed_id where fi.read_at = 0 and fl.account_id = ? group by feed_id;'),
+ readAllItems: writer.prepare(`update feed_items set read_at = datetime('now') where feed_id = ?`),
+ },
+ addFeed: (title: string, link: string, account_id: string) => {
+ const id = uuidv4();
+ query._.addFeed.run(id, title, link, account_id);
+ return {
+ id
+ }
+ },
+ readAllItems: (feed_id: string) => {
+ return query._.readAllItems.run(feed_id);
+ },
+ isFeedOwnedBy: (account_id: string, feed_id: string): boolean => {
+ const res = query._.getFeed.get(account_id, feed_id);
+ console.log('OUTPUT', res);
+ return !!res
+ },
+ getFeedList: (account_id: string) => {
+ return query._.getFeedList.all(account_id);
+ },
+ getUnreadCountForAll: (account_id: string) => {
+ return query._.getUnreadCountForAll.all(account_id);
+ },