Skip to content

Instantly share code, notes, and snippets.

@htkcodes
Created February 23, 2018 14:07
Show Gist options
  • Select an option

  • Save htkcodes/b177b317a1efdfccc07750f86227f413 to your computer and use it in GitHub Desktop.

Select an option

Save htkcodes/b177b317a1efdfccc07750f86227f413 to your computer and use it in GitHub Desktop.
//Remove field from document.
db.users.update({},{$unset:{cart:1}},{multi:true})
@htkcodes
Copy link
Author

console.log(count)
console.log(upsert);

                            if(err){throw err;}
                           if(count.nModified === 0)
                           {
                               User.update({
                                   _id:req.user._id,
                                   cart:cart.item
                               },{$inc:{'quantity':1}},function(){
                                   res.send("This item was already in your Cart"+`<br>`+"Quantity has been updated")
                               })
                           }
                           else{
                            res.send(true)
                           }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment