MongoDB: how to update only one element in the document?
问题 I want to updates only one element in the document to use put request I tried PUT localhost:3000/api/memo/5b8e382d61984255d879f872 { text: "updated!" { but, it updated like this { text: "updated!", imgUrl: null, tag: null, ... } Is there a way to updates one element in document? await Memo.where('_id') .equals(req.params.id) .updateOne({ imgUrl: req.body.imgUrl, text: req.body.text, tag: req.body.tag, user: req.body.user, loc: req.body.loc }) 回答1: You can use the following solution to update