僧侣-为什么我的更新有时只能工作?

时间:2019-02-20 01:52:00

标签: mongodb vue.js set monk

我正在使用MEVN Stack构建Web应用程序。我正在使用npm包“ Monk”与MongoDB通信。

我有一条将新文档插入到集合中的路由,当它被调用时,它也应该更新另一个集合中的文档。但是,这仅偶尔起作用,而有时却行不通。

这是我的通话代码

async function updateConccurentdays(id) {
    try {
        const result = await exercises.findOne({
            client_id: id
        }, {
            sort: {
                date: -1
            }
        }).catch((error) => {
            console.log("error in find " + error.message)
        });
        const rating = result.exercises[0].rating
        await clients.update(
            {id: id},
            {$set :{lastRating: rating}})
    } catch (error) {
        console.log("error in update " + error.message)
    }
}

问题出在我的clients.update()中,有时可以正常工作,有时我得到以下信息:   僧侣:查询更新:{“ n”:1,“ nModified”:0:“ ok”:1}

它不会更新文档。

0 个答案:

没有答案