Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "_id": "58fe27e0e340671c9859c995",
- "__v": 0,
- "form": [
- {
- "_id": "58fe2b1de437791cd02b9a8c",
- "sections": [
- {
- "_id": "58fe2b1de437791cd02b9a8d",
- "input": {
- "_type": "radio"
- }
- }
- ]
- },
- {
- "_id": "58fe2ca32470711c586d6b6e",
- "sections": []
- }
- ]
- }
- var save = function(req, res) {
- var survey = {};
- survey.id = req.params.surveyId; // 58fe27e0e340671c9859c995
- survey.form_id = req.params.formId; // 58fe2b1de437791cd02b9a8c
- survey.newObj = req.body.sections; // [{ input: {type: 'checkbox'}}]
- Survey.update(
- { _id: survey.id }, // 58fe27e0e340671c9859c995
- {$set:
- {'form': { _id: survey.form_id , sections: survey.newObj } }
- },
- {safe: true, upsert: true},
- function(err, model) {
- if (err)
- res.send(err);
- res.json(model);
- }
- );
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement