(id: string)
| 118 | } |
| 119 | |
| 120 | export async function deleteThread(id: string): Promise<void> { |
| 121 | const database = await getDB(); |
| 122 | // Get all message IDs in this thread for tombstones |
| 123 | const messages = await database.select<{ id: string }>( |
| 124 | "SELECT id FROM messages WHERE thread_id = ?", |
| 125 | [id], |
| 126 | ); |
| 127 | for (const msg of messages) { |
| 128 | await insertTombstone(database, msg.id, "messages"); |
| 129 | } |
| 130 | await insertTombstone(database, id, "threads"); |
| 131 | await database.execute("DELETE FROM messages WHERE thread_id = ?", [id]); |
| 132 | await database.execute("DELETE FROM threads WHERE id = ?", [id]); |
| 133 | } |
| 134 | |
| 135 | export async function deleteThreadsByBookId(bookId: string): Promise<void> { |
| 136 | const database = await getDB(); |
no test coverage detected