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
});

MongoError: Cannot update '__v' and '__v' at the same time,错误解决办法的更多相关文章

  1. Mysql之1451 - Cannot delete or update a parent row: a foreign key constraint fails...解决办法记录

    今天使用delete语句删除一张表中的一条信息时,提示了这么一个错误:1451 - Cannot delete or update a parent row: a foreign key constr ...

  2. MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法

    在MySQL中,写SQL语句的时候 ,可能会遇到You can't specify target table '表名' for update in FROM clause这样的错误,它的意思是说,不能 ...

  3. MySQL中You can't specify target table '表名'('sn_app_label') for update in FROM clause错误解决办法

    在有些时候有级联关系的数据放在了同一张表中,在写sql语句的时候可能会遇到这样的场景:我要插入两条数据,第一条是父节点,第二条是子节点,关联关系是父节点的自增长id:在写这样的sql语句时有可能就会出 ...

  4. apt-get update 101错误解决办法

    在一次装好Ubuntu系统, 执行 sudo apt-get update 时,报了错 " W: Failed to fetch http://security.ubuntu.com/ubu ...

  5. Mysql - You can't specify target table '表名' for update in FROM clause 错误解决办法

    背景 在MySQL中,写SQL语句的时候 ,可能会遇到 You can't specify target table '表名' for update in FROM clause 这样的错误 错误含义 ...

  6. pod setup 报CocoaPods was not able to update the `master` repo 错误解决办法

    先删除全局的缓存: $ sudo rm -fr ~/Library/Caches/CocoaPods/ $ sudo rm -fr ~/.cocoapods/repos/master/ 还不行的话就把 ...

  7. 【转】Cannot add or update a child row: a foreign key constraint fails 解决办法

    原因:设置的外键和对应的另一个表的主键值不匹配.解决方法:找出不匹配的值修改.或者清空两表数据. 转自https://blog.csdn.net/qq_29405421/article/details ...

  8. [转]MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法

    原文链接:https://blog.csdn.net/qq_29672495/article/details/72668008

  9. 运行sudo apt-get install nginx时报错有几个软件包无法下载,要不运行 apt-get update 或者加上 --fix-missing 的选项再试试?解决

    运行sudo apt-get install nginx时报错有几个软件包无法下载,要不运行 apt-get update 或者加上 --fix-missing 的选项再试试?解决办法 第一步:运行s ...

随机推荐

  1. easyUI-layout布局

    https://www.cnblogs.com/kexb/p/3685913.html <!DOCTYPE html><html><head> <meta c ...

  2. 总结Java虚拟机内存区域模型

    本篇文章主要来总结一下Java虚拟机内存的各个区域,以及这些区域的作用.服务对象以及其中可能产生的问题,作为大家的面试宝典. 首先我们来看一下Java运行时的数据区域,Java虚拟机在执行Java程序 ...

  3. 阿里云人脸识别测试接口出错 返回Body:{ "errno": 3002, "err_msg": "ILLEGAL_PARAMETERS", "request_id": "672cba83-cf93-4ef4-9ce5-d87e51601632" }

    错误信息如下 返回Body:{ "errno": 3002, "err_msg": "ILLEGAL_PARAMETERS", ...... ...

  4. 使用tensorflow构造隐语义模型的推荐系统

    先创建一个reader.py,后面的程序将用到其中的函数. from __future__ import absolute_import, division, print_function impor ...

  5. office web apps搭建与解决方案

    微软office在线预览解决方案https://view.officeapps.live.com/op/view.aspx?src=http://storage.xuetangx.com/public ...

  6. 【BZOJ1417】Pku3156 Interconnect

    题解: 比较简单的一道题 显然我们只需要知道每个联通块的大小就可以了 然后发现x1+xn=30 其中xi<=xi+1的状态只有5000 所以直接记忆化搜索就可以了 emm原来map还可以映射ve ...

  7. 【NPM】常见问题解决

    问题列表 问题一:npm install 执行报错 npm ERR! Unexpected end of JSON input while parsing near '...ependencies&q ...

  8. windows下面使用nssm设置新的服务实现开机自启等

    1.下载: http://nssm.cc/download/?page=download 2.解压: 根据自己的系统选择相应的32bit或者64bit,然后将相应的可执行文件拷贝到系统环境中.配置环境 ...

  9. 【AtCoder】ARC077

    C - pushpush 如果是按下标说的话 如果是偶数个 那么是 \(N,N - 2,N - 4...1,3,5...N - 1\) 如果是奇数个 \(N,N - 2,N - 4...2,4,6.. ...

  10. Python select解析

    一.首先列一下,sellect.poll.epoll三者的区别 1.select a.select最早于1983年出现在4.2BSD中,它通过一个select()系统调用来监控多个文件描述符的数组,当 ...