我有Question.findOne()
返回的以下数据结构:
Object
_id: "8132c2f0-baee-434f-a739-c4d30718daf2"
owner: "273b7291-df2b-494c-bd9b-64e71283447e"
question: "Vacations?"
answers: Array[1]
0: Object
name: "Cancun"
owned_by: "273b7291-df2b-494c-bd9b-64e71283447e"
__proto__: Object
我如何find
和return
使用mongodb _id "8132c2f0-baee-434f-a739-c4d30718daf2"
使用此文档获得一系列答案?这是我开始的地方:
Questions.find({}, {"answers.name":1})
答案 0 :(得分:0)
db.Questions.findOne({_id:"8132c2f0-baee-434f-a739-c4d30718daf2"}, {answers:1});
请同时查看文档:
http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields