{People:"1","Location":"US","Name":[{"first":"Tom","last":"Brady"},
{"first":"Jack","last":"Sparrow"},{"first":"Haha","last":"OhOh"}]}
我在MongoDB中有一些数据,数据结构是这样的,如何搜索“Tom”并且只返回
{People:"1","Location":"US","Name":[{"first":"Tom","last":"Brady"}]}
答案 0 :(得分:1)
试
db.collectionName.find({"Name.first": "Tom"}, {_id: 0, People: 1, Location: 1, "Name.$": 1});