title: an e-commerce project with MEAN
body: <p>I'm working on an e-commerce project and I'm stacked in when the customer chose the products to buy I store them in its cart and when he validates it I can't update the new value of the total quantity of the purchased product. </p>
  
  <p>I'm working with the MEAN technologies, for the mongoose models I have one for the Poduct
  the <strong>Product Model</strong> :</p>
  
  <pre><code>`var productModel = new Schema({
    title : {type:String,required : true},
    imgUrl : {type:String,required : true},
    price  :{type:Number,required : true},
    quantity : {type:Number,required : true},
    ref : {type:String,required : true},
    category : {type:String,required : true},
    descr : {type:String},
  });`
  
  and a **user Model** : 
  var User = new Schema({
    firstname : {type : String },
    lastname : {type : String },
    username : {type : String, unique : true },
    role : { type:String , default : "customer"},
    password : {type : String },
    cart : [{
      productId : String,
      title : String,
      imgUrl : String,
      price : Number,
      quantity : Number,
      qte : Number,
      totalPrice : Number
    }],
    purchasedProds : [{
      productId : String,
      title : String,
      imgUrl : String,
      price : Number,
      qte : Number,
      totalPrice : Number,
      date : {type : Date, default : Date.now}
    }]
  
  });
  </code></pre>
  
  <p>on the server side I'm using two routes, a <strong>productRouter</strong> to handle the products CRUD and a <strong>userRouter</strong> to handle the user authentication and its cart.
  when a user validates its cart I'll clear the cart field in the user collection and insert it into the <strong>purchasedProds</strong> field, I succeeded to do this by like I mentioned above I couldn't update the new value of the total quantity of a purchased product.
  I've been trying over 3 days but it don't work...please any help would be appreciated...thanks</p>