我想在mongodb中批量插入,但是如果记录已经存在,它应该用新的one.There is update命令替换它,但是在batch.Any中不可能这样做,我知道这是否可能吗?我使用的是java api。谢谢
编辑:由于我的集合大小不是很大,我正在重命名集合与放置目标选项设置为真,并创建一个新的集合与此data.As我不能冒险删除和创建一个新的集合这是更好的,但它将是可怕的,如果有替换成等同。
发布于 2011-07-23 13:03:53
如果您的集合中有任何主键,那么它将替换确保您的文档具有_id键的automatically.Make。
发布于 2014-03-21 09:57:29
请看mongodb文档:
Shorthand for insert/update is save - if _id value set, the record is updated if it exists or inserted if it does not; if the _id value is not set, then the record is inserted as a new one.在http://mongodb.github.io/node-mongodb-native/markdown-docs/insert.html中
https://stackoverflow.com/questions/6798337
复制相似问题