MongoDB的updateOne方法没有与猫鼬5.4.10工作
我试图用更新的方法updateOne的mongodb的记录,但它不工作。
async function updateCourse(id) {
const result = await Course.updateOne({_id : id }, { name: 'Abc'},
function(err, res) {});
console.log(result);
}
请人提出可能的解决方案来解决这个问题。
谢谢
回答如下:试试这个代码
const test = async function updateCourse(id) {
const result = await Course.updateOne({ _id: id }, { name: "Abc" })
console.log(result);
};
如果您在使用异步等待,不要再使用回调
我希望这可以帮助你。谢谢