PYMongo: Keep returning _id in every record after quering, How can I exclude this 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.
精彩评论