Removing _id element from Pymongo results

后端 未结 3 1943
挽巷
挽巷 2021-02-01 02:44

I\'m attempting to create a web service using MongoDB and Flask (using the pymongo driver). A query to the database returns documents with the \"_id\" field included, of course

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 03:20

    Above answer fails if we want specific fields and still ignore _id. Use the following in such cases:

    db.collection.find({'required_column_A':1,'required_col_B':1, '_id': False})
    

提交回复
热议问题