我已经在mongolab中创建了一个mongodb集合,并希望打印该collecton中的所有文档。我有mongolab,要连接到集合的mongolab的网址是-
mongodb://用户:[email protected]:41248/新
样本文档结构为-
{
"_id": "9759572745-Sing",
"details": {
"Gender": "M",
"PreTrainingStatus": "Fresher",
"Religion": "Hindu",
"attendanceInPercentage": "",
"batchHolders": {
"AssessmentDate": "Thu Jul 16 2015",
"CourseFee": "7500",
"isEditable": false
},
"batchID": "282726",
"eid": "",
"whereDidYouHearAboutStar": "---Select---",
"skillInstructorOrTrainerName": "282726",
"specificGovtInstitutetieups": "---Select---",
"isSelected": false,
"isEditable": false
},
"addedOnMs": 1439455766000,
"submittedOnMs": 1439454813000,
"latitude": "27.409566879272",
"longitude": "77.69295501709",
"locationName": "Uttar Pradesh 281006,null"
}
我想将其打印,并将所有嵌套属性显示在列中。但我无法这样做,请帮助。
先感谢您),
迪亚
最佳答案
您可以使用https://www.npmjs.com/package/json2csv
将nested
选项值设置为true
并且还指定您要从JSON获得的字段。对于嵌套文档,您可以像这样指定details.Gender