Skip to content

Commit 688c0d1

Browse files
committed
feat: javascript
1 parent 55fba15 commit 688c0d1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,15 @@ async chunkedBatch({ indexName, objects, action = 'addObject', waitForTasks, bat
317317
* @param saveObjects - The `saveObjects` object.
318318
* @param saveObjects.indexName - The `indexName` to save `objects` in.
319319
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
320+
* @param chunkedBatch.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.
320321
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
321322
*/
322323
async saveObjects(
323-
{ indexName, objects }: SaveObjectsOptions,
324+
{ indexName, objects, waitForTasks }: SaveObjectsOptions,
324325
requestOptions?: RequestOptions
325326
): Promise<BatchResponse[]> {
326327
return await this.chunkedBatch(
327-
{ indexName, objects, action: 'addObject' },
328+
{ indexName, objects, action: 'addObject', waitForTasks },
328329
requestOptions
329330
);
330331
},
@@ -336,17 +337,19 @@ async saveObjects(
336337
* @param deleteObjects - The `deleteObjects` object.
337338
* @param deleteObjects.indexName - The `indexName` to delete `objectIDs` from.
338339
* @param deleteObjects.objectIDs - The objectIDs to delete.
340+
* @param chunkedBatch.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.
339341
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
340342
*/
341343
async deleteObjects(
342-
{ indexName, objectIDs }: DeleteObjectsOptions,
344+
{ indexName, objectIDs, waitForTasks }: DeleteObjectsOptions,
343345
requestOptions?: RequestOptions
344346
): Promise<BatchResponse[]> {
345347
return await this.chunkedBatch(
346348
{
347349
indexName,
348350
objects: objectIDs.map((objectID) => ({ objectID })),
349351
action: 'deleteObject',
352+
waitForTasks,
350353
},
351354
requestOptions
352355
);

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

Lines changed: 2 additions & 2 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'> & {
135+
export type DeleteObjectsOptions = Pick<ChunkedBatchOptions, 'indexName' | 'waitForTasks'> & {
136136
/**
137137
* The objectIDs to delete.
138138
*/
@@ -151,7 +151,7 @@ export type PartialUpdateObjectsOptions = Pick<
151151

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

157157
export type ChunkedBatchOptions = ReplaceAllObjectsOptions & {

0 commit comments

Comments
 (0)