我用findOneAndUpdate函数进行mongodb数据库进行更新的时候,前端post数据之后,将原有的数组进行替换成提交过来的数据
let res = await this.findOneAndUpdate({
openid
}, {
$set: {
write,
notice
}
}, {
new: true
})
经过上面的代码更新之后,我通过Studio 3T查看数据库的时候,发现一次操作居然这个数组里面有四条数据,这是为什么?希望大佬帮忙解答一下
前端数据
数据库截图
没用过mongoose, 猜测是不是前端post的数据结构有问题, 改成这种看能不能行.
{
}