0
我剛剛開始使用node
,express
框架和mongo
作爲數據庫。貓鼬查詢結果丟失字段
我創造了這樣的模式:
var JsonSchema = new Schema({
type: String,
properties: {
OBJECTID: Number,
AREA: Number,
PERIMETER: Number,
ESYE_CODE: Number,
Descriptio: String
},
geometry: {
type: String,
coordinates: [Number, Number]
}
});
,然後我查詢:
router.get('/mapjson/:OBJECTID', function(req, res) {
if(req.params.OBJECTID) {
Json.findOne({OBJECTID: req.params.OBJECTID }, {}, function(err, docs){
res.json(docs);
} else {
console.log("THERE WAS AN ERROR HERE!!!");
}
});
但結果我得到缺少geometry
領域。結果
樣品獲得:
{
"_id":"57e43ec60534d33ccc13099b",
"type":"Feature",
"properties":{
"OBJECTID":212428,
"AREA":131.001991421,
"PERIMETER":49.9141344212,
"ESYE_CODE":147,
"Descriptio":"Ελληνικά"
}
}
和我所得到的,當我查詢從蒙戈外殼的集合:
db.points.findOne({'properties.OBJECTID': 212428})
{
"_id" : ObjectId("57e43ec60534d33ccc13099b"),
"type" : "Feature",
"properties" : {
"OBJECTID" : 212428,
"AREA" : 131.001991421,
"PERIMETER" : 49.9141344212,
"ESYE_CODE" : 147,
"Descriptio" : "Ελληνικά"
},
"geometry" : {
"type" : "Point",
"coordinates" : [
23.812561006040106,
38.093951650544334
]
}
}
res.json(是錯誤的 –
對不起,這是複製/粘貼錯誤,我修好了。 – Mes
req.params.OBJECTID,搜索的對象在數據庫中有幾何?只有找到所有可以很好的測試。 –