From f7d87e49f1ac1b5af58bf84b7f47088a7b310687 Mon Sep 17 00:00:00 2001 From: toptobes <96998732+toptobes@users.noreply.github.com> Date: Fri, 24 May 2024 13:14:48 -0500 Subject: [PATCH] changed default chunk size to 50 (#44) --- src/data-api/collection.ts | 2 +- .../data-api/collection/insert-many.test.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/data-api/collection.ts b/src/data-api/collection.ts index 71e51efb..c136fb82 100644 --- a/src/data-api/collection.ts +++ b/src/data-api/collection.ts @@ -268,7 +268,7 @@ export class Collection { * @throws InsertManyError - If the operation fails. */ public async insertMany(documents: MaybeId[], options?: InsertManyOptions): Promise> { - const chunkSize = options?.chunkSize ?? 20; + const chunkSize = options?.chunkSize ?? 50; if (options?.vectors) { if (options.vectors.length !== documents.length) { diff --git a/tests/integration/data-api/collection/insert-many.test.ts b/tests/integration/data-api/collection/insert-many.test.ts index 522a53da..5667a991 100644 --- a/tests/integration/data-api/collection/insert-many.test.ts +++ b/tests/integration/data-api/collection/insert-many.test.ts @@ -36,6 +36,18 @@ describe('integration.data-api.collection.insert-many', () => { }); }); + it('should insertMany many documents', async () => { + const docs = Array.from({ length: 1000 }, (_, i) => ({ name: `Player ${i}` })); + const res = await collection.insertMany(docs); + assert.strictEqual(res.insertedCount, docs.length); + assert.strictEqual(Object.keys(res.insertedIds).length, docs.length); + + res.insertedIds.forEach((id) => { + assert.ok(typeof id as any === 'string'); + assert.doesNotThrow(() => new UUID(id)); + }); + }); + it('should insertMany documents with ids', async () => { const docs = [{ name: 'Inis Mona', _id: 1 }, { name: 'Helvetios', _id: 2 }, { name: 'Epona', _id: 3 }]; const res = await collection.insertMany(docs);