dai*_*yue 2 python bulk mongodb
我正在尝试使用批量查找来检索一组文档并返回该文档集,我想知道批量查找返回什么?我的代码是:
 def bulk_find(collection_name, key, value):
    bulk = db[collection_name].initialize_ordered_bulk_op()
    bulk.find({key: value})
    results = bulk.execute()
那么,bulk.find这里返回什么?该文档未对此进行任何说明。  
它是返回BulkWriteOperation实例。从文档 
find(selector)
Specify selection criteria for bulk operations.
Parameters: 
selector (dict): the selection criteria for update and remove operations.
Returns:    
A BulkWriteOperation instance, used to add update and remove operations to this bulk operation.
在pymongo 散装是一个写操作界面。如果要从某个集合中检索多个文档,则应使用相应集合的find方法。你只需要
results = db[collection_name].find({key:value})
此操作从collection返回所有文档,collection_name其中keyfield ==的值value。