Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. {
  2. "_id": "58fe27e0e340671c9859c995",
  3. "__v": 0,
  4. "form": [
  5. {
  6. "_id": "58fe2b1de437791cd02b9a8c",
  7. "sections": [
  8. {
  9. "_id": "58fe2b1de437791cd02b9a8d",
  10. "input": {
  11. "_type": "radio"
  12. }
  13. }
  14. ]
  15. },
  16. {
  17. "_id": "58fe2ca32470711c586d6b6e",
  18. "sections": []
  19. }
  20. ]
  21. }
  22.  
  23. var save = function(req, res) {
  24. var survey = {};
  25. survey.id = req.params.surveyId; // 58fe27e0e340671c9859c995
  26. survey.form_id = req.params.formId; // 58fe2b1de437791cd02b9a8c
  27. survey.newObj = req.body.sections; // [{ input: {type: 'checkbox'}}]
  28.  
  29. Survey.update(
  30. { _id: survey.id }, // 58fe27e0e340671c9859c995
  31. {$set:
  32. {'form': { _id: survey.form_id , sections: survey.newObj } }
  33. },
  34. {safe: true, upsert: true},
  35. function(err, model) {
  36. if (err)
  37. res.send(err);
  38. res.json(model);
  39. }
  40. );
  41. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement