I'm trying to add blockDate
into user db, but the code below doesn't make any changes. I checked out that data.username
and blockDate
are valid value. I get { ok: 0, n: 0, nModified: 0 }
from res
variable. how can I figure out what is wrong with this request?
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)
}
})