feat(utils): Introduce promiseAll util (#5543)

This commit is contained in:
Adrien de Peretti authored and GitHub committed 2023-11-08 08:48:48 +01:00
1 parent e4ce2f4e07
commit f90ba02087
99 files changed
+464 -297

No files matched your search

@@ -21,6 +21,7 @@
},
"dependencies": {
"@babel/plugin-transform-classes": "^7.15.4",
"@medusajs/utils": "workspace:^",
"@shopify/shopify-api": "^1.4.1",
"axios": "^0.21.4",
"body-parser": "^1.19.0",
@@ -1,5 +1,6 @@
import { BaseService } from "medusa-interfaces"
import { INCLUDE_PRESENTMENT_PRICES } from "../utils/const"
import { promiseAll } from "@medusajs/utils"
class ShopifyService extends BaseService {
constructor(
@@ -83,11 +84,10 @@ class ShopifyService extends BaseService {
updatedSinceQuery
)
const resolvedProducts = await Promise.all(
const productServiceTx = this.productService_.withTransaction(manager)
const resolvedProducts = await promiseAll(
products.map(async (product) => {
return await this.productService_
.withTransaction(manager)
.create(product)
return await productServiceTx.create(product)
})
)