我有一个包含国家/地区记录的集合,我需要找到带有 uid 的特定国家,它是 countryId
以下是样本采集数据:
{
"uid": 15024,
"countries": [{
"countryId": 123,
"popullation": 45000000
},
{
"countryId": 456,
"poppulation": 9000000000
}
]
},
{
"uid": 15025,
"countries": [{
"countryId": 987,
"popullation": 560000000
},
{
"countryId": 456,
"poppulation": 8900000000
}
]
}
我在 python 中尝试了以下查询,但找不到任何结果:
foundRecord = collection.find_one({"uid" : 15024, "countries.countryId": 456})
但它返回无。
请帮助和建议。