diff --git a/packages/server/src/db/doc.ts b/packages/server/src/db/doc.ts index 0afa8d2..9ccfc9f 100644 --- a/packages/server/src/db/doc.ts +++ b/packages/server/src/db/doc.ts @@ -21,6 +21,20 @@ class SqliteDocumentAccessor implements DocumentAccessor { throw new Error("Method not implemented."); } async addList(content_list: DocumentBody[]): Promise { + if (content_list.length === 0) return []; + if (content_list.length > 256) { + // if content_list is too long, split it. + const chunkLength = 256; + const chunked = []; + for (let i = 0; i < content_list.length; i += chunkLength) { + chunked.push(content_list.slice(i, i + chunkLength)); + } + const ids = []; + for (const chunk of chunked) { + ids.push(await this.addList(chunk)); + } + return ids.flat(); + } return await this.kysely.transaction().execute(async (trx) => { // add tags const tagCollected = new Set();