Skip to content

Commit b162a3d

Browse files
SPIRIT-0: fix batch function params spread
1 parent 7ec92f5 commit b162a3d

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

libs/db/generics/operations/batch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ export const runBatchOperation = async <Actions extends ActionsType>(
4646
);
4747

4848
const queries = actions
49-
.map((action, index) => action?.query(params[index]))
49+
.map((action, index) => action?.query(...(params[index] ?? [])))
5050
.filter((action) => action !== undefined) as NonEmptyArray<
5151
BatchItem<"sqlite">
5252
>;
5353

5454
if (!queries.length) {
5555
throw Error("No queries provided in batch operation");
5656
}
57+
5758
const results = await db().batch(queries);
5859

5960
const mappedResults = [];

libs/modules/cart/use-cases/patch-cart-item-quantity.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ export const patchCartItemQuantity = async (
2828

2929
if (finalQuantity > stock) throw errors.PRODUCT_OUT_OF_STOCK(stock);
3030

31-
const cartOperation = getCartOperation(
31+
const cartOperationType = getCartOperationType(
3232
quantity,
3333
cartQuantity,
3434
finalQuantity,
3535
stock,
3636
);
3737

38-
const cart = await cartOperationMap[cartOperation](
38+
const cart = await cartOperationMap[cartOperationType](
3939
productId,
4040
cartId,
4141
finalQuantity,
@@ -44,7 +44,7 @@ export const patchCartItemQuantity = async (
4444
return extendCart(toCartDTO(cart));
4545
};
4646

47-
const getCartOperation = (
47+
const getCartOperationType = (
4848
quantity: number,
4949
cartQuantity: number,
5050
finalQuantity: number,

0 commit comments

Comments
 (0)