How can i get the latest totalQuantity in below code after $inc: { totalQuantity: -el.loadingTotal } operation? I am stuck at this point. Any ideas??
promiseArray.push(
Stock.updateOne(
{
index: el.index,
product: el.product,
batchNo: el.batchNo,
agency,
totalQuantity: { $gte: el.loadingTotal },
},
{
$push: {
reservations: {
loadingSheetId: sheetAfterSave._id,
reservedCaseQuantity: el.loadingCaseCount,
reservedUnitQuantity: el.loadingUnitCount,
reservedTotalQuantity: el.loadingTotal,
},
},
$inc: { totalQuantity: -el.loadingTotal },
$set: { currentQuantity: }, // How can i get the updated totalQuantity here
},
{
session: session,
}
)
);