博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mongodb list 大量插入数据 Bulk()
阅读量:4199 次
发布时间:2019-05-26

本文共 1200 字,大约阅读时间需要 4 分钟。

在mongodb2.6以后 使用  Bulk()

 or the method.

得到bulk

var bulk = db.users.initializeOrderedBulkOp();bulk.insert( { user: "abc123", status: "A", points: 0 } );bulk.insert( { user: "ijk123", status: "A", points: 0 } );bulk.insert( { user: "mop123", status: "P", points: 0 } );bulk.find( { status: "D" } ).remove();bulk.find( { status: "P" } ).update( { $set: { comment: "Pending" } } );bulk.execute();

如果有一个失败,剩余的会终止,执行是顺序执行的

详细:https://docs.mongodb.org/manual/reference/method/db.collection.initializeOrderedBulkOp/#db.collection.initializeOrderedBulkOp

:

https://docs.mongodb.org/manual/reference/method/db.collection.initializeUnorderedBulkOp/#db.collection.initializeUnorderedBulkOp

var bulk = db.users.initializeUnorderedBulkOp();bulk.insert( { user: "abc123", status: "A", points: 0 } );bulk.insert( { user: "ijk123", status: "A", points: 0 } );bulk.insert( { user: "mop123", status: "P", points: 0 } );bulk.execute();

Each group of operations can have at most . If a group exceeds this , MongoDB will divide the group into smaller groups of 1000 or less. For example, if the bulk operations list consists of 2000 insert operations, MongoDB creates 2 groups, each with 1000 operations.

如果操作过多,会切分成1000个操作

转载地址:http://qodli.baihongyu.com/

你可能感兴趣的文章
linux -8 Linux磁盘与文件系统的管理
查看>>
linux -8 Linux磁盘与文件系统的管理
查看>>
linux 9 -文件系统的压缩与打包 -dump
查看>>
PHP在变量前面加&是什么意思?
查看>>
ebay api - GetUserDisputes 函数
查看>>
ebay api GetMyMessages 函数
查看>>
wdlinux
查看>>
关于mysql升级到5.5报错问题
查看>>
magento - 通过storeid,分类id,天数(几天内)得到产品
查看>>
一个很不错的bash脚本编写教程,至少没接触过BASH的也能看懂!
查看>>
Redis和Memcache对比及选择
查看>>
用谷歌账号登陆magento、
查看>>
php oauth 模块在linux下安装
查看>>
代替nginx的服务器 - The Tengine Web Server
查看>>
nginx 升级成 tengine 的代码
查看>>
magento rest api 调用
查看>>
magento rest api 调用!
查看>>
magento rest api get Token key and secret
查看>>
谷歌获取货币汇率代码
查看>>
安装nginx
查看>>