如何使用pymongo获得仅ObjectId的列表? [英] How do I get a list of just the ObjectId's using pymongo?

查看:339
本文介绍了如何使用pymongo获得仅ObjectId的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

client = MongoClient()
data_base = client.hkpr_restore
agents_collection = data_base.agents
agent_ids = agents_collection.find({},{"_id":1})

这给了我以下结果:

{u'_id': ObjectId('553020a8bf2e4e7a438b46d9')}
{u'_id': ObjectId('553020a8bf2e4e7a438b46da')}
{u'_id': ObjectId('553020a8bf2e4e7a438b46db')}

如何获取ObjectId,然后可以使用每个ID来搜索另一个集合?

How do I just get at the ObjectId's so I can then use each ID to search another collection?

推荐答案

使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆