MongoDb : How to insert additional object into object collection?

前端 未结 2 617
执念已碎
执念已碎 2021-02-13 14:00

I have a document \"owner\" that can have \"n\" number of camps and camps have \"instructors\" and instructors have \"classes\". Earlier I tried accomplishing this with nested a

2条回答
  •  逝去的感伤
    2021-02-13 14:37

    var newObject = {usuario: req.body.usuario, fecha: req.body.fecha, edit: 
    req.body.edit};
    
    await Documentos.findByIdAndUpdate(id,
     { deleted_doc: true,
     $push: { history: newObject } }); 
    res.json({ status: 'Documentos Updated' });
    

提交回复
热议问题