node.js中JSON嵌套格式,数组查询不到
1,json的数据格式为
{
"_id" : ObjectId("59959a4ea007718916839e81"),
"fid" : "5987fabbb48f868e50acf8ca",
"coordinates" : [
120.487171,
36.107046
]
}
2,mongoose访问代码
//返回数据库查询结果
Geo.find( {coordinates: {
$nearSphere: {
$geometry: {
type: "Point",
coordinates:[120.487364,36.106383]
},
$maxDistance:500
}
}
}).exec(function(err,results){
var arr = null;
for(var key in results){
console.log(results[key].coordinates);
}
3,查询结果
4,但是访问其他的关键字正常
console.log(results[key].fid);
我这边本地测试查询没问题,2dsphere 索引添加了吗