* Insert or update a file record
(file: FileRecord)
| 1863 | * Insert or update a file record |
| 1864 | */ |
| 1865 | upsertFile(file: FileRecord): void { |
| 1866 | if (!this.stmts.upsertFile) { |
| 1867 | this.stmts.upsertFile = this.db.prepare(` |
| 1868 | INSERT INTO files (path, content_hash, language, size, modified_at, indexed_at, node_count, errors) |
| 1869 | VALUES (@path, @contentHash, @language, @size, @modifiedAt, @indexedAt, @nodeCount, @errors) |
| 1870 | ON CONFLICT(path) DO UPDATE SET |
| 1871 | content_hash = @contentHash, |
| 1872 | language = @language, |
| 1873 | size = @size, |
| 1874 | modified_at = @modifiedAt, |
| 1875 | indexed_at = @indexedAt, |
| 1876 | node_count = @nodeCount, |
| 1877 | errors = @errors |
| 1878 | `); |
| 1879 | } |
| 1880 | |
| 1881 | this.stmts.upsertFile.run({ |
| 1882 | path: file.path, |
| 1883 | contentHash: file.contentHash, |
| 1884 | language: file.language, |
| 1885 | size: file.size, |
| 1886 | modifiedAt: file.modifiedAt, |
| 1887 | indexedAt: file.indexedAt, |
| 1888 | nodeCount: file.nodeCount, |
| 1889 | errors: file.errors ? JSON.stringify(file.errors) : null, |
| 1890 | }); |
| 1891 | } |
| 1892 | |
| 1893 | /** |
| 1894 | * Delete a file record and its nodes |
no test coverage detected