Spaces:
Sleeping
Sleeping
File size: 628 Bytes
0330133 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | export const TableService = {
occupy: async (TableModel, tableId, invoiceId) => {
return TableModel.findByIdAndUpdate(
tableId,
{
status: "occupied",
currentOrderId: invoiceId || null, // ✅ track which invoice owns this table
},
{ new: true, runValidators: true }
);
},
free: async (TableModel, tableId) => {
return TableModel.findByIdAndUpdate(
tableId,
{
status: "available",
currentOrderId: null, // ✅ always clear the invoice ref when freeing
},
{ new: true, runValidators: true }
);
},
}; |