I have a small problem with findByIdAndUpdate in mongoose:
my code:
const editCarrito = await Carrito.findByIdAndUpdate(req.params.id, {pedido:{ cantidad: cantidad, bebidas:bebidas.toString(), rentrega: rentrega}, comentarios:{vegetariano: vegetariano.toString(),retirar: retirar, adicional: adicional}})
The problem:
I have this data stored in mongoDB:
saving editcarrito deletes important data such as type, name, platoid. I need that data to remain there and that is why I do not include them in order thinking that by not being there will not modify anything as happens with image or userid:
any ideas? Thanks in advance :)