fix(medusa): Missing withTransaction on update in get-cart.ts (#3246)
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): Get cart missing transaction on update
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { CartService } from "../../../../services"
|
import { CartService } from "../../../../services"
|
||||||
|
import { EntityManager } from "typeorm"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [get] /carts/{id}
|
* @oas [get] /carts/{id}
|
||||||
@@ -47,6 +48,7 @@ export default async (req, res) => {
|
|||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|
||||||
const cartService: CartService = req.scope.resolve("cartService")
|
const cartService: CartService = req.scope.resolve("cartService")
|
||||||
|
const manager: EntityManager = req.scope.resolve("manager")
|
||||||
|
|
||||||
const cart = await cartService.retrieve(id, {
|
const cart = await cartService.retrieve(id, {
|
||||||
select: ["id", "customer_id"],
|
select: ["id", "customer_id"],
|
||||||
@@ -59,9 +61,11 @@ export default async (req, res) => {
|
|||||||
!cart.email ||
|
!cart.email ||
|
||||||
cart.customer_id !== req.user.customer_id
|
cart.customer_id !== req.user.customer_id
|
||||||
) {
|
) {
|
||||||
await cartService.update(id, {
|
await manager.transaction(async (transctionManager) => {
|
||||||
|
await cartService.withTransaction(transctionManager).update(id, {
|
||||||
customer_id: req.user.customer_id,
|
customer_id: req.user.customer_id,
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user