Guest User

Untitled

a guest
Oct 12th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. USER: {
  2. _id: objectId(as425as4526dc)
  3. username: 'admin',
  4. password: 'a61a8726ahf604s',
  5. fname: 'first',
  6. lname: 'last',
  7. date: '2018-9-9',
  8. orders: [
  9. {
  10. _id: objectID(012eoisadn3)
  11. status: 0,
  12. name: 'name'
  13. description: 'hello'
  14. }
  15. ]
  16. }
  17.  
  18. const username = req.body.username;
  19. const orderID = req.body.id;
  20. const newStatus = req.body.status;
  21.  
  22. User.update(
  23. {
  24. username: username,
  25. 'orders._id': orderID
  26. },
  27. {
  28. $set:{
  29. 'orders.$.status': newStatus
  30. }
  31. },
  32. function(err,docs){
  33. ...
  34. //Do Stuff Here
  35. ...
  36. }
  37. );
Add Comment
Please, Sign In to add comment