Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into main
  • Loading branch information
swapnil-ahlawat committed Mar 28, 2021
2 parents 986333d + 22b0141 commit 2dc275a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Backend/controllers/user-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ const getOrders= async(req, res, next) =>{
const removeOrder= async(req, res, next) =>{
const{orderID, phoneNo}= req.body;

let identifiedUser= await User.updateOne({phoneNo}, {$pull: {orders: {orderID}}});
// let orderArray=[]
// for (index = 0; index < identifiedUser.orders.length; index++) {
// if(indentifiedUser.orders[index].orderID!==orderID){
// orderArray.push(identifiedUser.orders[index]);
// }
// }
// console.log(orderArray);
// identifiedUser.orders= orderArray;
// identifiedUser.save();
const identifiedUser = await User.findOne({phoneNo});
if(!identifiedUser)
{
return res.sendCode(404);
}
identifiedUser.orders = identifiedUser.orders.filter(p => {
return p.orderID !== orderID;
});
await identifiedUser.save();

res.json({
message: 'Order removed Successfully!',
user: identifiedUser
Expand Down

0 comments on commit 2dc275a

Please sign in to comment.