remove lock on inventory
This commit is contained in:
@@ -137,7 +137,7 @@ export class InventoryService {
|
|||||||
bulkReserveFoodDto: BulkReserveFoodDto,
|
bulkReserveFoodDto: BulkReserveFoodDto,
|
||||||
): Promise<Inventory[]> {
|
): Promise<Inventory[]> {
|
||||||
return em.transactional(async em => {
|
return em.transactional(async em => {
|
||||||
|
|
||||||
const { items } = bulkReserveFoodDto;
|
const { items } = bulkReserveFoodDto;
|
||||||
// Get all unique food IDs
|
// Get all unique food IDs
|
||||||
const foodIds = [...new Set(items.map(item => item.foodId))];
|
const foodIds = [...new Set(items.map(item => item.foodId))];
|
||||||
@@ -160,7 +160,7 @@ export class InventoryService {
|
|||||||
// Load all existing inventories in one query
|
// Load all existing inventories in one query
|
||||||
const existingInventories = await em.find(Inventory, {
|
const existingInventories = await em.find(Inventory, {
|
||||||
food: { id: { $in: foodIds } },
|
food: { id: { $in: foodIds } },
|
||||||
},{ lockMode: LockMode.PESSIMISTIC_WRITE });
|
});
|
||||||
|
|
||||||
const inventoryMap = new Map<string, Inventory>();
|
const inventoryMap = new Map<string, Inventory>();
|
||||||
for (const inventory of existingInventories) {
|
for (const inventory of existingInventories) {
|
||||||
|
|||||||
Reference in New Issue
Block a user