How to select a single field in MongoDB using Pymongo?

后端 未结 3 1754
梦如初夏
梦如初夏 2021-01-04 06:52

I\'m trying to find a record within MongoDB, and filter _id from the result.

Here is my code:

#app.py
@app.route(\'/login\', methods = [         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-04 07:07

    it is the best way for avoiding id,

    data = db.author.find_one({'email' : email, 'password' : password},{"password":1, "email":1, "name":1,"_id": False})
    

    now you got ANSWER "{'password': '123123', 'name': 'prakash', 'email': 'prakashprabhu48@gmail.com'}"(without id)

提交回复
热议问题