I would like to do this using MongoDB aggregation-framework, is this possible?
db.objects.aggregate([
{$match:
{$and:[
{location:{$nearSphere:{$geometry:{type:"Point",coordinates:[latitude, longitude]},$minDistance:x,$maxDistance:y}}},
{date1:{$gte:date2}
]
}
},
{$project:ratio
{$divide:[
{$subtract:[date1,date2]},
{result of a function returning distance between this location and latitude, longitude in parameters}
]
}
},
{$sort:{ratio:-1}}
]);
Is this possible to do this with db.collection.group({ key, reduce, initial [, keyf] [, cond] [, finalize] }) ?...