【发布时间】:2018-04-30 11:16:29
【问题描述】:
我是 MongoDB 和 node.js 的初学者。实际上,我正在尝试获取特定文档的名称,但我想知道该怎么做。 让我详细说明: 如果“a”是一个包含名为“student”的文档的集合,并且“student”包含像
这样的字段{
"_id: "student",
"name": "alex",
"roll": "3",
"age":"13"
}
那么如何获取["name","roll","age"]格式的字段名
通过尝试:
db.collection("user").find({ "_id": "student" }).toArray(function(err, result) {
console.log(result)
})
为所有字段提供它们的值。
【问题讨论】: