({
db,
docName
}: {
db: Low<Schema>;
docName: string;
})
| 138 | } |
| 139 | |
| 140 | export async function deleteDocumentFromDB({ |
| 141 | db, |
| 142 | docName |
| 143 | }: { |
| 144 | db: Low<Schema>; |
| 145 | docName: string; |
| 146 | }): Promise<void> { |
| 147 | if (!db.data.documents[docName]) { |
| 148 | throw new Error(`Document with name "${docName}" does not exist`); |
| 149 | } |
| 150 | |
| 151 | // Delete all chunks associated with the document |
| 152 | for (const chunkId of db.data.documents[docName].chunkIds) { |
| 153 | delete db.data.chunks[chunkId]; |
| 154 | } |
| 155 | |
| 156 | delete db.data.documents[docName]; |
| 157 | await db.write(); |
| 158 | } |
| 159 | |
| 160 | export async function addChunksBulk( |
| 161 | { |
no outgoing calls
no test coverage detected