CREATE TABLE ITEM (
    `id` TEXT NOT NULL,
    `datetime` TEXT NOT NULL,
    `title` TEXT NOT NULL,
    `content` TEXT NOT NULL,
    `unread` INTEGER AS Boolean DEFAULT 0 NOT NULL,
    `starred` INTEGER AS Boolean DEFAULT 0 NOT NULL,
    `thumbnail` TEXT,
    `icon` TEXT,
    `link` TEXT NOT NULL,
    `sourcetitle` TEXT NOT NULL,
    `tags` TEXT NOT NULL,
    `author` TEXT,
    PRIMARY KEY(`id`)
);

CREATE INDEX item_title ON ITEM(`title`);
CREATE INDEX item_source ON ITEM(`sourcetitle`);


items:
SELECT * FROM ITEM ORDER BY `id` DESC;

insertItem:
INSERT OR REPLACE INTO ITEM VALUES ?;

deleteItem:
DELETE FROM ITEM WHERE `id` = ?;

deleteItemsWhereSource:
DELETE FROM ITEM WHERE `sourcetitle` = ?;

updateItem:
UPDATE ITEM SET `datetime` = ?, `title` = ?, `content` = ?, `unread` = ?, `starred` = ?, `thumbnail` = ?, `icon` = ?, `link` = ?, `sourcetitle` = ?, `tags` = ?, `author` = ? WHERE `id` = ?;