这是我的drivers
集合:
{
"_id" : ObjectId("57e9efd94c02272f4029b5c6"),
"driverId" : 386,
"firstname" : "John",
"middlename" : null,
"lastname" : "Doe",
"loc" : {
"type" : "Point",
"coordinates" : [
36.29102901,
-1.29012381
]
},
"driverState" : "available",
"contacts" : {
"email" : "email@email.com",
"phoneNumber" : "07000000",
"imei" : "",
"gcmCode" : ""
},
"vehicle" : {
"vehicleId" : 0,
"registration" : null,
"capacity" : 4,
"vehicleClass" : "GOLD",
"model" : null,
"colour" : null
},
"cabCompany" : {
"cabCompanyId" : 8,
"name" : "princeton cabs"
}
}
我想将最近的驱动程序提取到按vehicle.vehicleClass
和vehicle.capacity
分组的地理位置。
因此,如果我将GOLD,SILVER
作为vehicle.vehicleClass
和4,7
的可能值vehicle.capacity
作为GOLD,4
的可能值,则查询最多应返回四个文档:
GOLD,7
,SILVER,4
,SILVER,7
和db.drivers.aggregate([
{
$match: {
loc: {
$near: {
$geometry: {
type: "Point",
coordinates: [36.2901920192,
-1.29102939202]
},
$maxDistance: 100000
}
}
}
},
{
$group: {
_id: {
"vehicle.vehicleClass": "$vehicle.vehicleClass", "vehicle.capacity":"$vehicle.capacity"
}
}
}
])
,其中每个结果最接近所提供的地理点。
可能如何用mongo
转换为spring-data这是我尝试的但是我收到了错误:匹配内不允许$ near
Meteor.onConnection(function(conn) {
console.log(conn.clientAddress);
console.log(FlowRouter.getRouteName());
var id = database.insert({
page: "page",
ip: conn.clientAddress,
enterdPagedAt: new Date(),
isActive: true
});