(note: Note)
| 69 | } |
| 70 | |
| 71 | export async function insertNote(note: Note): Promise<void> { |
| 72 | const database = await getDB(); |
| 73 | const deviceId = await getDeviceId(); |
| 74 | const syncVersion = await nextSyncVersion(database, "notes"); |
| 75 | await database.execute( |
| 76 | "INSERT INTO notes (id, book_id, highlight_id, cfi, title, content, chapter_title, tags, created_at, updated_at, sync_version, last_modified_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", |
| 77 | [ |
| 78 | note.id, |
| 79 | note.bookId, |
| 80 | note.highlightId || null, |
| 81 | note.cfi || null, |
| 82 | note.title, |
| 83 | note.content, |
| 84 | note.chapterTitle || null, |
| 85 | JSON.stringify(note.tags), |
| 86 | note.createdAt, |
| 87 | note.updatedAt, |
| 88 | syncVersion, |
| 89 | deviceId, |
| 90 | ], |
| 91 | ); |
| 92 | } |
| 93 | |
| 94 | export async function updateNote(id: string, updates: Partial<Note>): Promise<void> { |
| 95 | const database = await getDB(); |
no test coverage detected