bulk_write
可以批量进行如下:
bulk_data = []
for i in range(1000): name = f’s{i}’ _filter = {‘id’: i} _update = {‘$set’: {‘name’: name}} bulk_data.append(pymongo.UpdateOne(_filter, _update, upsert=True)) col.bulk_write(bulk_data)
<a name="XIows"></a>
#### 批量插入
```python
bulk_data = []
for i in range(1000):
data = pymongo.InsertOne({'id', i, 'name': f's{i}'})
bulk_data.append(data)
col.bulk_write(bulk_data)