Skip to content

Commit 0598874

Browse files
committed
feat: isConcurrent argument for batch method
If isConcurrent is true then each URI calls are made asynchronously. The result will be the same once all calls are processed.
1 parent 37201b7 commit 0598874

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/Api.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,16 @@ export class Api {
492492
* @param {boolean} isAtomic Pass true if you want all operations to happen in the same transaction.
493493
* There is a limitation, however. Atomic batch operations can only return success or error.
494494
*
495+
* @param {boolean} isConcurrent Requests to the DB are made asynchronously.
496+
*
495497
* @returns {Promise<any[] | undefined>}
496498
*/
497-
batch(uriCollector: (batchApi: IBatchApi) => string[], isAtomic?: false): Promise<any[]>
498-
batch(uriCollector: (batchApi: IBatchApi) => string[], isAtomic?: true): Promise<undefined>
499+
batch(uriCollector: (batchApi: IBatchApi) => string[], isAtomic?: false, isConcurrent?: boolean): Promise<any[]>
500+
batch(uriCollector: (batchApi: IBatchApi) => string[], isAtomic?: true, isConcurrent?: boolean): Promise<undefined>
499501
batch(
500502
uriCollector: (batchApi: IBatchApi) => string[],
501-
isAtomic?: boolean
503+
isAtomic?: boolean,
504+
isConcurrent?: boolean
502505
): Promise<any[] | undefined> {
503506
const batchApi = batchApiFactory(this)
504507
const uris = uriCollector(batchApi)
@@ -509,7 +512,8 @@ export class Api {
509512
'/batch',
510513
{
511514
atomic: !!isAtomic,
512-
uri: uris
515+
uri: uris,
516+
concurrent: !!isConcurrent
513517
},
514518
undefined,
515519
Api.Methods.POST

0 commit comments

Comments
 (0)