Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USER: {
- _id: objectId(as425as4526dc)
- username: 'admin',
- password: 'a61a8726ahf604s',
- fname: 'first',
- lname: 'last',
- date: '2018-9-9',
- orders: [
- {
- _id: objectID(012eoisadn3)
- status: 0,
- name: 'name'
- description: 'hello'
- }
- ]
- }
- const username = req.body.username;
- const orderID = req.body.id;
- const newStatus = req.body.status;
- User.update(
- {
- username: username,
- 'orders._id': orderID
- },
- {
- $set:{
- 'orders.$.status': newStatus
- }
- },
- function(err,docs){
- ...
- //Do Stuff Here
- ...
- }
- );
Add Comment
Please, Sign In to add comment