pymongo 如何查询一个字典数组中的某个KEY对应某个值?
如下的mongo文档,要查询MemberList里面的列表是否有"Uin" : 1589615073的列表项,"NickName" : "暖暖的",如果有返回这个列表项,而不是整个文档?
请教大神这应该怎么查询
{
"_id" : ObjectId("5831b10d3a5ef837e46ccdb2"),
"UserName" : "@@5e053d26153e603bbb2a9c615a37482c740673b166e54eb9bceab3fa30502626",
"City" : "",
"DisplayName" : "",
"UniFriend" : 0,
"MemberList" : [
{
"UserName" : "@fd6b0f325e4daa1eb7e5c1fae0c13991950e6e32a4a58e3e8aa51f2a2fc6a663",
"RemarkPYQuanPin" : "",
"DisplayName" : "",
"KeyWord" : "",
"PYInitial" : "",
"Uin" : NumberLong(2720082935),
"RemarkPYInitial" : "",
"PYQuanPin" : "",
"MemberStatus" : 0,
"NickName" : "天",
"AttrStatus" : NumberLong(2147586117)
},
{
"UserName" : "@8956e035c85ab0aa722d2b12c7c6cae9332de68e9aade6433e41ad805387ae0a",
"RemarkPYQuanPin" : "",
"DisplayName" : "",
"KeyWord" : "",
"PYInitial" : "",
"Uin" : 40283062,
"RemarkPYInitial" : "",
"PYQuanPin" : "",
"MemberStatus" : 0,
"NickName" : "员",
"AttrStatus" : NumberLong(2147487781)
},
{
"UserName" : "@73416f68eac03cfd77833f90fb023f664d7380740deef5d8043dc2400c0ef8a7",
"RemarkPYQuanPin" : "",
"DisplayName" : "",
"KeyWord" : "",
"PYInitial" : "",
"Uin" : 1589615073,
"RemarkPYInitial" : "",
"PYQuanPin" : "",
"MemberStatus" : 0,
"NickName" : "暖暖的",
"AttrStatus" : 16781349
},
{
"UserName" : "@a1bf7a55ad8478017b95124774687769",
"RemarkPYQuanPin" : "",
"DisplayName" : "",
"KeyWord" : "iss",
"PYInitial" : "",
"Uin" : 12266535,
"RemarkPYInitial" : "",
"PYQuanPin" : "",
"MemberStatus" : 0,
"NickName" : "一二三",
"AttrStatus" : NumberLong(2181050407)
},
{
"UserName" : "@5571e120b5d8f54f93338c76f62b9c419b818c29373dca9f331c2911a203bfbe",
"RemarkPYQuanPin" : "",
"DisplayName" : "",
"KeyWord" : "",
"PYInitial" : "",
"Uin" : NumberLong(3379331828),
"RemarkPYInitial" : "",
"PYQuanPin" : "",
"MemberStatus" : 0,
"NickName" : "灵灵八",
"AttrStatus" : 4133
}
],
"PYQuanPin" : "qunhaoquerenqun2",
"RemarkPYInitial" : "",
"Uin" : "7555117026@chatroom",
"AppAccountFlag" : 0,
"VerifyFlag" : 0,
"Province" : "",
"KeyWord" : "",
"RemarkName" : "",
"self" : {
"UserName" : "@4babcdd9789c909048a51a069eb37b635f4f79bc5dfc2b5ae6e7325e16848e2b",
"RemarkPYQuanPin" : "",
"DisplayName" : "",
"KeyWord" : "",
"PYInitial" : "",
"Uin" : 1589615073,
"RemarkPYInitial" : "",
"PYQuanPin" : "",
"MemberStatus" : 0,
"NickName" : "暖暖的",
"AttrStatus" : 4133
},
"ChatRoomId" : 0,
"isAdmin" : false,
"ContactType" : 0,
"HideInputBarFlag" : 0,
"EncryChatRoomId" : "@96c72d96a6c3f9936768b28ffbfaadff",
"AttrStatus" : 0,
"Statues" : 1,
"SnsFlag" : 0,
"MemberCount" : 5,
"OwnerUin" : NumberLong(2720082935),
"Alias" : "",
"Signature" : "",
"ContactFlag" : 2,
"NickName" : "群号确认群2",
"ChatRoomOwner" : "@1f6ddf50c372ba088a9b8f61670a8cfa5873ede35810a60b4076486eac6c20e2",
"RemarkPYQuanPin" : "",
"HeadImgUrl" : "/cgi-bin/mmwebwx-bin/webwxgetheadimg?seq=0&username=@@5e053d26153e603bbb2a9c615a37482c740673b166e54eb9bceab3fa30502626&skey=",
"Sex" : 0,
"StarFriend" : 0,
"PYInitial" : "QHQRQ2",
"HeadImgUpdateFlag" : 1,
"effectCate" : "测试"
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用$elemMatch实现