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
});
MongoError: Cannot update '__v' and '__v' at the same time,错误解决办法的更多相关文章
- 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 ...
- 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这样的错误,它的意思是说,不能 ...
- MySQL中You can't specify target table '表名'('sn_app_label') for update in FROM clause错误解决办法
在有些时候有级联关系的数据放在了同一张表中,在写sql语句的时候可能会遇到这样的场景:我要插入两条数据,第一条是父节点,第二条是子节点,关联关系是父节点的自增长id:在写这样的sql语句时有可能就会出 ...
- apt-get update 101错误解决办法
在一次装好Ubuntu系统, 执行 sudo apt-get update 时,报了错 " W: Failed to fetch http://security.ubuntu.com/ubu ...
- 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 这样的错误 错误含义 ...
- pod setup 报CocoaPods was not able to update the `master` repo 错误解决办法
先删除全局的缓存: $ sudo rm -fr ~/Library/Caches/CocoaPods/ $ sudo rm -fr ~/.cocoapods/repos/master/ 还不行的话就把 ...
- 【转】Cannot add or update a child row: a foreign key constraint fails 解决办法
原因:设置的外键和对应的另一个表的主键值不匹配.解决方法:找出不匹配的值修改.或者清空两表数据. 转自https://blog.csdn.net/qq_29405421/article/details ...
- [转]MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法
原文链接:https://blog.csdn.net/qq_29672495/article/details/72668008
- 运行sudo apt-get install nginx时报错有几个软件包无法下载,要不运行 apt-get update 或者加上 --fix-missing 的选项再试试?解决
运行sudo apt-get install nginx时报错有几个软件包无法下载,要不运行 apt-get update 或者加上 --fix-missing 的选项再试试?解决办法 第一步:运行s ...
随机推荐
- selenium 操作键盘
send_keys(Keys.ENTER) 按下回车键send_keys(Keys.TAB) 按下Tab制表键send_keys(Keys.SPACE) 按下空格键spacesend_keys(Kye ...
- C#的值传递与引用传递
值传递:在使用值传递时,是把变量的值传给函数,函数中对此变量的任何修改都不影响该变量本身的值. 引用传递:使用引用传递时,在函数中对此变量的修改会影响变量的值. 说简单点,值传递,就是我把身份证复印件 ...
- checkbox选中相关问题总结
html: <input type="checkbox" name="fruit" id="apple">苹果 <inpu ...
- 安装CentOS 7(转)
转载地址:https://www.cnblogs.com/wcwen1990/p/7630545.html CentOS7安装详解 本文基于vmware workstations进行CentOS7 ...
- drone的pipeline原理与代码分析
最近的一个项目,需要实现一个工作任务流(task pipeline),基于之前CICD的经验,jenkins pipeline和drone的pipeline进入候选. drone是基于go的cicd解 ...
- docker-java Docker的java API
docker-java docker-java 是 Docker的 Java 版本API Docker 当前的实现基于 Jersey 2.x 因此 classpath 不兼容老版本的 Jersey 1 ...
- python全栈开发day66-视图系统、路由系统
一.昨日内容回顾 1. tags 1. for循环 {% for name in name_list %} {{ name }} {% endfor %} {% for name in name_li ...
- WPF中datagrid不显示滚动条问题
WPF中DataGrid是自带滚动条的,当内容显示不下时可以使用滚动条显示.但是,开发中遇到了DataGrid一直不显示滚动条.之前也曾遇到过同类问题,再次经过查找,发现是StackPanel的原因, ...
- mySql中SUBSTRING_INDEX函数用法
SUBSTRING_INDEX(str,delim,count) 返回字符串 str 中在第 count 个出现的分隔符 delim 之前的子串.如果 count 是一个正数,返回从最后的(从左边开始 ...
- UOJ#351. 新年的叶子 概率期望
原文链接https://www.cnblogs.com/zhouzhendong/p/UOJ351.html 题目传送门 - UOJ351 题意 有一个 n 个节点的树,每次涂黑一个叶子节点(度为 1 ...