(
{
db,
docName,
chunks
}: { db: Low<Schema>; docName: string; chunks: Omit<Chunk, 'id'>[] } // Array of chunks, each omitting the id field
)
| 158 | } |
| 159 | |
| 160 | export async function addChunksBulk( |
| 161 | { |
| 162 | db, |
| 163 | docName, |
| 164 | chunks |
| 165 | }: { db: Low<Schema>; docName: string; chunks: Omit<Chunk, 'id'>[] } // Array of chunks, each omitting the id field |
| 166 | ): Promise<void> { |
| 167 | if (!db.data.documents[docName]) { |
| 168 | throw new Error(`Document with name "${docName}" does not exist`); |
| 169 | } |
| 170 | |
| 171 | for (const chunk of chunks) { |
| 172 | const id = crypto.randomUUID(); |
| 173 | const newChunk = ChunkSchema.parse({ ...chunk, id }); |
| 174 | db.data.chunks[id] = newChunk; |
| 175 | db.data.documents[docName].chunkIds.push(id); |
| 176 | } |
| 177 | |
| 178 | await db.write(); |
| 179 | } |
| 180 | |
| 181 | export async function getDocumentsFromMemory( |
| 182 | memoryNames: string[] |
no outgoing calls
no test coverage detected