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 ... 
随机推荐
- 如何获取jar包的在执行机上面的路径
			背景: 最近在项目中遇到一个小问题, 几行代码就能解决了 String path = this.getClass().getProtectionDomain().getCodeSource().get ... 
- 中软酒店管理系统CSHIS操作手册_数据结构_数据字典
			https://wenku.baidu.com/view/f6ca11f5ee06eff9aef807cb.html 
- SQL 查询表的第一条数据 和 最后一条数据
			方法一: 使用TOP SELECT TOP 1 * FROM user; SELECT TOP 1 * FROM user order by id desc; 方法二: 使用LIMIT SELECT ... 
- CentOS6.9安装Filebeat监控Nginx的访问日志发送到Kafka
			一.下载地址: 官方:https://www.elastic.co/cn/downloads/beats/filebeat 百度云盘:https://pan.baidu.com/s/1dvhqb0 二 ... 
- [转]MySQL忘记密码的正确解决方法
			http://database.51cto.com/art/201005/201986.htm 以下的文章主要介绍的是MySQL忘记密码的正确解决方法,在实际操作中如果你忘记MySQL密码是一件很头痛 ... 
- 通俗理解webService及.net中的使用方法
			什么是WebService? WebService两个关键字:HTTP.接口 WebService就是一个接口,与普通接口的区别就是:普通接口只能本地调用:WebService可以远程调用. WebS ... 
- Python_os模块
			os模块:可以处理文件和目录,是Python系统和操作系统进行交互的一个接口 os模块常用方法: os.getcwd(): 获取当前工作目录,(即当前Python脚本工作的目录路径) os.chdir ... 
- axios中文文档
			Axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中. Features 从浏览器中创建 XMLHttpRequests 从 node.js 创建 http ... 
- 51Nod1038 X^A Mod P 数论 原根 BSGS
			原文链接https://www.cnblogs.com/zhouzhendong/p/51Nod1038.html 题目传送门 - 51Nod1038 题意 题解 在模质数意义下,求高次剩余,模板题. ... 
- sql 把一个用逗号分隔的多个数据字符串变成一个表的一列
			USE [tms]GO/****** Object: UserDefinedFunction [dbo].[StrToTable] Script Date: 2017/4/26 9:06:20 *** ... 
