doushang7209 2019-02-27 11:58
浏览 53
已采纳

用mgo两次插入而不是一次插入

Im new in Golang and Im building a Golang CRUD using mgo framework to practice. When I insert one element using mgo, is inserted two times instead of one time, I ckecked it in MongoDB Compass Community. This is my repository

This is a picture showing how is being saved in my database:

enter image description here

Can anybody help me?

  • 写回答

1条回答 默认 最新

  • dpkk8687 2019-02-27 12:14
    关注

    Your code inserts a single document only. If it would insert 2, properties (except the _id field) would be identical / same.

    And your 2 documents have different time field, thus they are from 2 different runs.

    So what you see is the result of 2 different runs (2 seconds away from each other), either by you or by your IDE.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作