【发布时间】:2018-03-19 02:27:52
【问题描述】:
我使用 Node.JS 作为后端,使用 Angular4 作为前端。
我想使用 findOneAndUpdate 将某行中的 angular 更改为数组
这是我的模特
subLot: [{
room: String,
beforePicture: String,
afterPicture: String,
Realisations: [{
realisationName : String,
specialtyName : String,
pu: Number,
unite: String,
quantite: Number,
startDate: Date, // Attribute to Update
endDate: Date, // Attribute to Update
}]
}]
更改将在 "startDate" "endDate" 中:
(let body = req.body.subLot) subLot[x].room == body[x].room && subLot[x].Realisations[y].realisationName == body[x].Realisations[y].realisationName
这是我在 Node.JS 中的函数
var lot = Devis.
findOneAndUpdate({ "project": req.params.projectId }, { "$set": { "subLot": req.body.subLot } }).
exec(function (err, lot) {
if (err) {
res.status(500).send(err);
return;
}
res.status(200).json({ lot: lot, success: true });
return;
})
【问题讨论】: