0
{
"_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);
}
);
};
I would like to replace what is inside the object array (sections
) whole for a new object array: [{ input: {_type: 'checkbox'}}]
in the position of _id: 58fe2b1de437791cd02b9a8c
my Function save is not working.