mongodb E11000 duplicate key error collection: index: _id_ dup key
今天在单测的时候,出现这个问题。
我代码只定义了一个变量
let body = {name: 'wu'}
然后连续2次插入这个body数据
await exam.insertExam(body);
await exam.insertExam(body);
这样就生成了相同的_id.
mongdb可能会认为body是同一个数据,只生成了一个_id;
当又新建了一个变量body2,
就不会报错了。
mongodb E11000 duplicate key error collection: index: _id_ dup key的更多相关文章
- E11000 duplicate key error index: test.collection.$a.b_1 dup key: { : null } 报错记录
这个一般分为两种情况,第一新增数据出现约束.而你在orm里面写了唯一约束.这种情况就比较简单,添加数据时保证数据字段唯一性就好了. 第二种情况比较难找,因为你发现你在orm里面并没有写约束,但是还是插 ...
- E11000 duplicate key error index
E11000 duplicate key error index mongodb插入报错,重复主键问题,有唯一键值重复 一般使用collection.insertOne(doc);插入一条已存在主键的 ...
- Oracle deadlock SX/SSX caused by no index on foreign key.
Example to show the dead lock caused by lack of index on foreign key of child table. Session 1: crea ...
- 【异常】update更新java.sql.SQLException: Duplicate entry '2019-07-30 00:00:00-110100' for key
1 详细异常信息 User class threw exception: java.sql.SQLException: Duplicate entry '2019-07-30 00:00:00-110 ...
- Fix the “No Private Key” Error Message
This article will show you how to correct the “No Private Key” error message in Windows Internet Inf ...
- java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^
1 String a = "1991\12\16"; 2 String[] split = a.split("\\"); 3 System.out.printl ...
- Error Code: 1068. Multiple primary key defined
1.错误描述 10:10:38 alter table user add num int(8) primary key first Error Code: 1068. Multiple primary ...
- [转] Linux有问必答:如何修复“sshd error: could not load host key”
编译自:http://ask.xmodulo.com/sshd-error-could-not-load-host-key.html作者: GOLinux 本文地址:https://linux.cn/ ...
- 【err】VIDEOIO ERROR: V4L: index 0 is not correct!Unable to connect to camera
前言 新到手一块板子,程序编译成功之后,运行出现错误,不能连接到摄像头. 问题 VIDEOIO ERROR: V4L: index is not correct! Unable to connect ...
随机推荐
- vue路由传值params和query的区别
vue路由传值params和query的区别1.query传参和接收参数传参: this.$router.push({ path:'/xxx' query:{ id:id } })接收参数: this ...
- oracle用户锁定
https://www.cnblogs.com/lostyue/archive/2011/12/06/2278063.html
- HTML页面直接显示json 结构
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- Qt之窗体拖拽、自适应分辨率、自适应大小
简述 在自定义无边框.标题栏的界面中,需要自己实现最小化.最大化.关闭.窗体背景等功能.最小化.最大化.关闭等按钮设计及功能比较简单,这里就不多做介绍.今天主要介绍一下绘制背景的问题,主要实现自适应屏 ...
- Keil5.15版本号
Keil5.15下载地址 http://pan.baidu.com/s/1kT6AGvX Keil5.15软件补丁下载地址 http://www.keil.com/dd2/pack/ Keil5.15 ...
- Oracle 学习笔记 14 -- 集合操作和高级子查询
Oracel提供了三种类型的集合操作:各自是并(UNION) .交(INTERSECT). 差(MINUS) UNION :将多个操作的结果合并到一个查询结果中,返回查询结果的并集,自己主动去掉反复的 ...
- offsetLeft,Left,clientLeft具体解释
假设 obj 为某个 HTML 控件. obj.offsetTop 指 obj 相对于版面或由 offsetParent 属性指定的父坐标的计算上側位置,整型,单位像素. obj.offsetLe ...
- select into in mysql
http://stackoverflow.com/questions/16809393/select-into-in-mysql Use the CREATE TABLE SELECT syntax. ...
- zzuoj--10424--无聊的课(简单几何)
10424: 无聊的课 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 81 Solved: 16 [Submit][Status][Web Boar ...
- Android UnitTest FrameWork
Android test suites基于Junit,可以直接使用Junit测试不使用android api的class,也可以使用android的Junit extensions测试android ...