【发布时间】:2019-02-09 11:00:13
【问题描述】:
我只想更新文档中的一个元素以使用 put 请求
我试过了
PUT 本地主机:3000/api/memo/5b8e382d61984255d879f872
{
text: "updated!"
{
但是,它是这样更新的
{
text: "updated!",
imgUrl: null,
tag: null,
...
}
有没有办法更新文档中的一个元素?
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
})
【问题讨论】:
标签: mongodb mongoose mongodb-query