Skip to content

Commit c08ac94

Browse files
committed
chore: javascript
1 parent 8522705 commit c08ac94

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

templates/javascript/clients/client/api/helpers.mustache

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,16 @@ async chunkedBatch({ indexName, objects, action = 'addObject', waitForTasks, bat
318318
* @param saveObjects - The `saveObjects` object.
319319
* @param saveObjects.indexName - The `indexName` to save `objects` in.
320320
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
321+
* @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
321322
* @param saveObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
322323
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
323324
*/
324325
async saveObjects(
325-
{ indexName, objects, waitForTasks }: SaveObjectsOptions,
326+
{ indexName, objects, waitForTasks, batchSize }: SaveObjectsOptions,
326327
requestOptions?: RequestOptions
327328
): Promise<BatchResponse[]> {
328329
return await this.chunkedBatch(
329-
{ indexName, objects, action: 'addObject', waitForTasks },
330+
{ indexName, objects, action: 'addObject', waitForTasks, batchSize },
330331
requestOptions
331332
);
332333
},
@@ -338,11 +339,12 @@ async saveObjects(
338339
* @param deleteObjects - The `deleteObjects` object.
339340
* @param deleteObjects.indexName - The `indexName` to delete `objectIDs` from.
340341
* @param deleteObjects.objectIDs - The objectIDs to delete.
342+
* @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
341343
* @param deleteObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
342344
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
343345
*/
344346
async deleteObjects(
345-
{ indexName, objectIDs, waitForTasks }: DeleteObjectsOptions,
347+
{ indexName, objectIDs, waitForTasks, batchSize }: DeleteObjectsOptions,
346348
requestOptions?: RequestOptions
347349
): Promise<BatchResponse[]> {
348350
return await this.chunkedBatch(
@@ -351,6 +353,7 @@ async deleteObjects(
351353
objects: objectIDs.map((objectID) => ({ objectID })),
352354
action: 'deleteObject',
353355
waitForTasks,
356+
batchSize,
354357
},
355358
requestOptions
356359
);
@@ -364,11 +367,12 @@ async deleteObjects(
364367
* @param partialUpdateObjects.indexName - The `indexName` to update `objects` in.
365368
* @param partialUpdateObjects.objects - The array of `objects` to update in the given Algolia `indexName`.
366369
* @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail..
370+
* @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
367371
* @param partialUpdateObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
368372
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
369373
*/
370374
async partialUpdateObjects(
371-
{ indexName, objects, createIfNotExists, waitForTasks }: PartialUpdateObjectsOptions,
375+
{ indexName, objects, createIfNotExists, waitForTasks, batchSize }: PartialUpdateObjectsOptions,
372376
requestOptions?: RequestOptions
373377
): Promise<BatchResponse[]> {
374378
return await this.chunkedBatch(
@@ -378,6 +382,7 @@ async partialUpdateObjects(
378382
action: createIfNotExists
379383
? 'partialUpdateObject'
380384
: 'partialUpdateObjectNoCreate',
385+
batchSize,
381386
waitForTasks
382387
},
383388
requestOptions

templates/javascript/clients/client/model/clientMethodProps.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export type SearchClientNodeHelpers = {
132132
}
133133
{{/isSearchClient}}
134134

135-
export type DeleteObjectsOptions = Pick<ChunkedBatchOptions, 'indexName' | 'waitForTasks'> & {
135+
export type DeleteObjectsOptions = Pick<ChunkedBatchOptions, 'indexName' | 'waitForTasks' | 'batchSize'> & {
136136
/**
137137
* The objectIDs to delete.
138138
*/
@@ -141,7 +141,7 @@ export type DeleteObjectsOptions = Pick<ChunkedBatchOptions, 'indexName' | 'wait
141141

142142
export type PartialUpdateObjectsOptions = Pick<
143143
ChunkedBatchOptions,
144-
'indexName' | 'objects' | 'waitForTasks'
144+
'indexName' | 'objects' | 'waitForTasks' | 'batchSize'
145145
> & {
146146
/**
147147
*To be provided if non-existing objects are passed, otherwise, the call will fail.
@@ -151,7 +151,7 @@ export type PartialUpdateObjectsOptions = Pick<
151151

152152
export type SaveObjectsOptions = Pick<
153153
ChunkedBatchOptions,
154-
'indexName' | 'objects' | 'waitForTasks'
154+
'indexName' | 'objects' | 'waitForTasks' | 'batchSize'
155155
>;
156156

157157
export type ChunkedBatchOptions = ReplaceAllObjectsOptions & {

0 commit comments

Comments
 (0)