我正在尝试添加blockDate
到用户数据库中,但下面的代码没有进行任何更改。我检查了它data.username
并且blockDate
是有效值。我{ ok: 0, n: 0, nModified: 0 }
从res
变量中得到。我怎样才能弄清楚这个请求有什么问题?
router.post('/account/block', async (ctx, next) => {
let data = ctx.request.body
let fixedDate = parseInt(data.days)
let blockDate = DateTime.local().plus({days: fixedDate}).toISO()
let param = {
search: { username: data.username},
update: { $set: {blockDate: blockDate}}
}
try {
console.log(param)
let res = await User.update(param.search, param.update, {multi: true})
console.log("res", res)
} catch (e) {
console.log("err", e)
}
})