wip: implement bookmark preview
This commit is contained in:
@@ -22,18 +22,14 @@ VALUES ($id, $userId, $kind, $title, $url)
|
||||
insert(DEMO_BOOKMARKS)
|
||||
}
|
||||
|
||||
function insertBookmark(bookmark: Bookmark, user: User) {
|
||||
const query = db.query(`
|
||||
INSERT INTO bookmarks (id, user_id, kind, title, url)
|
||||
VALUES ($id, $userId, $kind, $title, $url)
|
||||
`)
|
||||
query.run({
|
||||
id: bookmark.id,
|
||||
userId: user.id,
|
||||
kind: bookmark.kind,
|
||||
title: bookmark.title,
|
||||
url: bookmark.url,
|
||||
})
|
||||
function findBookmarkHtml(id: string, user: User): string | null {
|
||||
const query = db.query("SELECT content_html FROM bookmarks WHERE id = $id AND user_id = $userId")
|
||||
const row = query.get({ id, userId: user.id })
|
||||
if (!row) {
|
||||
return null
|
||||
}
|
||||
const { content_html } = row as { content_html: string }
|
||||
return content_html
|
||||
}
|
||||
|
||||
export { insertDemoBookmarks }
|
||||
export { insertDemoBookmarks, findBookmarkHtml }
|
||||
|
Reference in New Issue
Block a user