Skip to content

Commit f7d87e4

Browse files
authored
changed default chunk size to 50 (#44)
1 parent 14257fe commit f7d87e4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/data-api/collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
268268
* @throws InsertManyError - If the operation fails.
269269
*/
270270
public async insertMany(documents: MaybeId<Schema>[], options?: InsertManyOptions): Promise<InsertManyResult<Schema>> {
271-
const chunkSize = options?.chunkSize ?? 20;
271+
const chunkSize = options?.chunkSize ?? 50;
272272

273273
if (options?.vectors) {
274274
if (options.vectors.length !== documents.length) {

tests/integration/data-api/collection/insert-many.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ describe('integration.data-api.collection.insert-many', () => {
3636
});
3737
});
3838

39+
it('should insertMany many documents', async () => {
40+
const docs = Array.from({ length: 1000 }, (_, i) => ({ name: `Player ${i}` }));
41+
const res = await collection.insertMany(docs);
42+
assert.strictEqual(res.insertedCount, docs.length);
43+
assert.strictEqual(Object.keys(res.insertedIds).length, docs.length);
44+
45+
res.insertedIds.forEach((id) => {
46+
assert.ok(typeof id as any === 'string');
47+
assert.doesNotThrow(() => new UUID(<any>id));
48+
});
49+
});
50+
3951
it('should insertMany documents with ids', async () => {
4052
const docs = [{ name: 'Inis Mona', _id: 1 }, { name: 'Helvetios', _id: 2 }, { name: 'Epona', _id: 3 }];
4153
const res = await collection.insertMany(docs);

0 commit comments

Comments
 (0)