Javascript 关于mongodb查询
我有一个文档,其中Javascript 关于mongodb查询,javascript,mongodb,Javascript,Mongodb,我有一个文档,其中奖励字段定义如下: "awards" : { "oscars" : [ {"award": "bestAnimatedFeature", "result": "won"}, {"award": "bestMusic", "result": "won"}, {"award": "bestPicture", "result": "nominated"}, {"award": "bestSoundEditin
奖励
字段定义如下:
"awards" :
{
"oscars" : [
{"award": "bestAnimatedFeature", "result": "won"},
{"award": "bestMusic", "result": "won"},
{"award": "bestPicture", "result": "nominated"},
{"award": "bestSoundEditing", "result": "nominated"},
{"award": "bestScreenplay", "result": "nominated"}
],
"wins" : 56,
"nominations" : 86,
"text" : "Won 2 Oscars. Another 56 wins and 86 nominations."
}
我想在find()命令中使用查询文档来返回此集合中所有获得最佳影片奖或提名最佳影片奖的影片?
基本上,我想计算一下“奥斯卡”数组中的“奖项”在哪里等于“最佳图片”。我不明白,但这很简单:
db.awards.find({"awards.oscars.award" : "bestPicture"},
{_id:1,"awards.text":1})
第二部分是只显示电影的Id和标题