采取以下措施。_id = 1
我可以通过执行以下操作来提取匹配“1967”的记录。是否可以打印与 1967 年匹配的奖项和与“Penn”匹配的学校名称?
db.bios.find({_id:1, "awards.year" : 1967},{"awards.$":1}).pretty()
db.bios.insert(
{
_id: 1,
awards: [
{
award: 'W.W. McDowell Award',
year: 1967,
by: 'IEEE Computer Society'
},
{
award: 'National Medal of Science',
year: 1975,
by: 'National Science Foundation'
},
],
"schools" : [
{
name : "Harvard",
year : 1945
},
{
name : "Penn",
year : 1950
}
]
}
)