(limit = 50)
| 41 | |
| 42 | /** Get all notes across all books (for general chat without bookId) */ |
| 43 | export async function getAllNotes(limit = 50): Promise<Note[]> { |
| 44 | const database = await getDB(); |
| 45 | const rows = await database.select<{ |
| 46 | id: string; |
| 47 | book_id: string; |
| 48 | highlight_id: string | null; |
| 49 | cfi: string | null; |
| 50 | title: string; |
| 51 | content: string; |
| 52 | chapter_title: string | null; |
| 53 | tags: string; |
| 54 | created_at: number; |
| 55 | updated_at: number; |
| 56 | }>("SELECT * FROM notes ORDER BY created_at DESC LIMIT ?", [limit]); |
| 57 | return rows.map((r) => ({ |
| 58 | id: r.id, |
| 59 | bookId: r.book_id, |
| 60 | highlightId: r.highlight_id || undefined, |
| 61 | cfi: r.cfi || undefined, |
| 62 | title: r.title, |
| 63 | content: r.content, |
| 64 | chapterTitle: r.chapter_title || undefined, |
| 65 | tags: parseJSON(r.tags, []), |
| 66 | createdAt: r.created_at, |
| 67 | updatedAt: r.updated_at, |
| 68 | })); |
| 69 | } |
| 70 | |
| 71 | export async function insertNote(note: Note): Promise<void> { |
| 72 | const database = await getDB(); |
no test coverage detected