Skip to content

Commit

Permalink
changed default chunk size to 50 (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
toptobes authored May 24, 2024
1 parent 14257fe commit f7d87e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/data-api/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
* @throws InsertManyError - If the operation fails.
*/
public async insertMany(documents: MaybeId<Schema>[], options?: InsertManyOptions): Promise<InsertManyResult<Schema>> {
const chunkSize = options?.chunkSize ?? 20;
const chunkSize = options?.chunkSize ?? 50;

if (options?.vectors) {
if (options.vectors.length !== documents.length) {
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/data-api/collection/insert-many.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(<any>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);
Expand Down

0 comments on commit f7d87e4

Please sign in to comment.