0
我在MongoDB中的文檔:節點將找不到蒙戈嵌套文件稱爲選項
{
"_id": "56aa92d81a4bfbec1c8ed8e2",
/* other attributes */
"chartSettings": {
"title": {
"text": "Student Grouped by Credit Load"
},
"yAxis": {
"title": "Students"
},
"xAxis": {
"title": "Credit Load"
},
"options": {
"chart": {
"type": "areaspline"
}
}
},
/* other attributes */
"data": [
/* array of data objects */
],
"__v": 7
}
當我使用蒙戈CLI客戶端,我可以看到chartSettings.options
但是當我在節點查詢/快速一點也沒有」通過。不知道爲什麼,我已經確認它不是JSON.stringify
。這裏是我的快遞路由器代碼:
reports.find({}, function (err, reports) {
if (err) return res.send('Error: '+err);
console.log(reports[0].chartSettings); //console shows options: {}
res.send(JSON.stringify(reports));
});
MongoClient:
"chartSettings" : {
"options" : {
"chart" : {
"type" : "column"
}
},
"title" : {
"text" : "Student Grouped by Credit Load"
},
"yAxis" : {
"title" : "Students"
},
"xAxis" : {
"title" : "Credit Load"
}
},
和節點Express服務器控制檯:
GET /data/mongo/reports/ 200 12.466 ms - 5732
{ options: {},
title: { text: 'Student Grouped by Credit Load' },
yAxis: { title: 'Students' },
xAxis: { title: 'Credit Load' },
opts: { chart: { type: 'areaspline' } } }
數據中的__v'鍵表示您正在使用貓鼬。架構中如何定義「選項」?可能應該是'Mixed'。 –