我正在尝试使用批量查找来检索一组文档并返回该文档集,我想知道批量查找返回的内容是什么?我的代码是:
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
其中key
field ==的值value
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句