0

我有以下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

如何使用 mongodbfindreturn本文档中的一系列答案?_id "8132c2f0-baee-434f-a739-c4d30718daf2"这是我开始的地方:

Questions.find({}, {"answers.name":1})
4

1 回答 1

0
db.Questions.findOne({_id:"8132c2f0-baee-434f-a739-c4d30718daf2"}, {answers:1});

另请查看文档:

http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields

于 2012-10-29T15:30:46.893 回答