| 66 | |
| 67 | // File operations |
| 68 | insertFile(file: FileRecord): number { |
| 69 | const stmt = this.db.prepare(` |
| 70 | INSERT INTO files (path, hash, size, language, modified_at, indexed_at, line_count, token_count) |
| 71 | VALUES (?, ?, ?, ?, ?, ?, ?, ?) |
| 72 | ON CONFLICT(path) DO UPDATE SET |
| 73 | hash = excluded.hash, |
| 74 | size = excluded.size, |
| 75 | language = excluded.language, |
| 76 | modified_at = excluded.modified_at, |
| 77 | indexed_at = excluded.indexed_at, |
| 78 | line_count = excluded.line_count, |
| 79 | token_count = excluded.token_count |
| 80 | `); |
| 81 | |
| 82 | const result = stmt.run( |
| 83 | file.path, |
| 84 | file.hash, |
| 85 | file.size, |
| 86 | file.language, |
| 87 | file.modified_at, |
| 88 | file.indexed_at, |
| 89 | file.line_count, |
| 90 | file.token_count |
| 91 | ); |
| 92 | |
| 93 | return result.lastInsertRowid as number; |
| 94 | } |
| 95 | |
| 96 | getFile(path: string): FileRecord | undefined { |
| 97 | const stmt = this.db.prepare('SELECT * FROM files WHERE path = ?'); |