zoukankan      html  css  js  c++  java
  • MongoError: Cannot update '__v' and '__v' at the same time,错误解决办法

    1.讲查询的结果,原封不动的插入到另一个表中,结果报错了:MongoError: Cannot update '__v' and '__v' at the same time,起初认为是mongodb副本集出现问题了,排查了mongodb,确定不是数据库问题了

    看到这篇文章解决了https://stackoverflow.com/questions/33626456/mongoerror-exception-cannot-update-v-and-v-at-the-same-time

    直接上解决的代码:

    const userFind = await model.user.findById(userId)

    const userInsert = userFind.toJSON();//查询出来的就是JSON,但是,删除__V的时候,插入bakuser表,还是报错MongoError: Cannot update '__v' and '__v' at the same time,最后,在userFInd后加了toJOSN方法,就完全解决了

    delete userInsert.__v;

    await model.bakuser.update({
    _id: userId
    }, {
    $set: userInsert
    }, {
    upsert: true
    });

  • 相关阅读:
    vue 插件的使用 todolist案例
    vue 传值 混入mixin
    vue 生命周期函数
    vue 指令总结
    vue 其它的指令
    vue 监听数据变化的原理 表单数据的收集
    vue for循环中的key
    vue 学习
    vue 学习
    HDU 1029
  • 原文地址:https://www.cnblogs.com/qiyc/p/9857439.html
Copyright © 2011-2022 走看看