📜  猫鼬等待保存 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:38.482000             🧑  作者: Mango

代码示例1
try {
  const newUser = new User({
    'email': req.body.email,
    'name': req.body.name
  });
  console.log('before save');
  let saveUser = await newUser.save(); //when fail its goes to catch
  console.log(saveUser); //when success it print.
  console.log('after save');
} catch (err) {
  console.log('err' + err);
  res.status(500).send(err);
}