NEXTJS,MONGODB-updateOne不起作用?

时间:2020-06-04 08:15:35

标签: mongodb next.js

我尝试在NEXTJS上实现Mongodb的updateOne函数。 但是它不会更新,可以从console.log(req.body)获取信息。

max.request.size

请帮助验证我错过了什么????? 预先非常感谢。

以下是console.log(req.body);

的结果
handler.patch(async (req, res) => {
  if (!req.user) {
    res.status(401).end();
    return;
  }
  const { name, bio } = req.body;
  await req.db.collection('users').updateOne(
    { _id: req.user._id },
    {
      $set: {
        ...(name && { name }),
        bio: bio || '',
      },
    },
  );
  res.json({ user: { name, bio } });
});

所以我不确定我是否能获得正确的信息。

0 个答案:

没有答案