[英]Pymongo: how to get the value of a specific field
I have the document below. 我有下面的文件。 I would like to get the topic field if the password matches.
如果密码匹配,我想获取主题字段。
email: "info@info.com"
电子邮件:“info@info.com”
first_name: "james"first_name:“詹姆斯”
password: Binary('HcM0Js5Pqh8oGZxLSNuMJNgb5l1WUCn5NRhB/L4juIY=')密码:二进制('HcM0Js5Pqh8oGZxLSNuMJNgb5l1WUCn5NRhB / L4juIY =')
surname:"mcarthy" topic: "journalism"姓:“mcarthy”主题:“新闻”
I am using below code to check if the key exists. 我使用下面的代码来检查密钥是否存在。
user = user_in_db.find_one({'password': key})
if user is None:
How can i retrieve the topic field if the user does exist? 如果用户确实存在,我如何检索主题字段?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.