开发者

PYMongo: Keep returning _id in every record after quering, How can I exclude this record?

开发者 https://www.devze.com 2023-02-09 02:54 出处:网络
I am having problem when I do a query to mongodb using pymongo. I do not know how to avoid getting the _id for each record.

I am having problem when I do a query to mongodb using pymongo. I do not know how to avoid getting the _id for each record.

I am doing something like this,

result = db.meta.find(filters, [ 开发者_JAVA技巧 'model', 'fields.parent', 'fields.status', 'fields.slug', 'fields.firm', 'fields.properties'])

I do not want to iterate the cursor elements only to delete a field. Thanks,

Joaquin


You can exclude the id object this way:

db.meta.find({}, {"_id" : 0})


Does make any sense. The object id is core part of each document. Convert the BSON/JSON document to a native datastructure (depending on your implementation language) and remove _id on this level. Apart from that it does not make much sense what you are trying to accomplish.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号