I have an array called "previousEducation" which initially was empty array, but once I push an object into the array, I want each object that will be push into the array to have an object id. Although from the screenshot I uploaded, the object id was in both (1) and (2) but I don t need the aspect where I circled in (1) I want something inform of the one I named (2) where each object will be having an id follow by the req.body. Is there a way I can push req.body into the array and archive that.
感谢。
我的法典。
const {receivedEmail, ...myBody} = req.body
studentModel.findOneAndUpdate(
{email: req.body.receivedEmail},
{$push: {previousEducation:{ _id: new ObjectId(), myBody}}}
)
.then((response) => {
// console.log(response + JWT );
res.send({message: O level Result added successfully , status: true, response});
})
}```[![The image screenshot][1]][1]
[1]: https://i.stack.imgur.com/sztiw.png