我有这样的数据,我需要此mongodb集合中的所有键,例如property1,property2
等。
{
"_id": 0,
"config": [{
"property1":"a",
"property2": "b",
"property3": "c",
"property4": "d"
},
{
"property1": "a",
"property2": "bb",
"property3": "cc",
"property4": "d",
"ispropert5": true
},
{
"property1": "a",
"property2": "b",
"property3": "c",
"property4": "ddd",
"ispropert5": false,
"ispropert6": false
}
],
"entity": "123asdf",
"url": "",
"createdDate": 1
}
我尝试过
db.COLLECTION_NAME.find({},{config:1}).forEach(function(doc){Object.keys(doc).forEach(function(key){innerkeys[key]=1})}):
答案 0 :(得分:0)