我有这个查询:
db.places.aggregate([
{ "$geoNear" :
{ "near" :
{
"type" : "Point", "coordinates" : [23, 11]
}, "distanceField" : "distance",
"spherical" : true
}
},
{
"$sort" :
{ "distance" : 1 }
},
{
"$limit" : 10
}
])
哪个会返回
{
"_id":ObjectId("XXXX"),
"longitude":23.11,
"latitude":11.1995,
"distance":23.111995
}
但是,在 C# 等语言中,由于“距离”不是返回文档的 C# 类的一部分,因此会中断反序列化。
我怎样才能得到如下结果?
{
"document": {
"_id":ObjectId("XXXX"),
"longitude":23.11,
"latitude":11.1995
},
"distance":23.111995
}
谢谢你的帮助