Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我使用 pymongo 对 mongodb 进行查询时遇到问题。我不知道如何避免获取每条记录的 _id。
我正在做这样的事情,
结果 = db.meta.find(过滤器,['model','fields.parent','fields.status','fields.slug','fields.firm','fields.properties'])
我不想迭代游标元素只是为了删除一个字段。谢谢,
华金
您可以通过以下方式排除 id 对象:
db.meta.find({}, {"_id" : 0})
有什么意义。对象 id 是每个文档的核心部分。将 BSON/JSON 文档转换为本机数据结构(取决于您的实现语言)并在此级别上删除 _id。除此之外,您要完成的工作没有多大意义。