I was wondering if there was a way of finding all messages in a Mongo collection that are within a specific distance, but with the distance specified by each message in the collection.
The collection is defined as:
var messageSchema = mongoose.Schema({
uid : String,
message : String,
geo : {type: [Number], index: '2d'},
distance : Number,
time : { type : Date, default: Date.now },
timeout : { type : Date } });
And I know you can use
Message.find({ geo: { $near: [lng, lat], $maxDistance: 100 }}).exec(function(err, messages){..});
To find messages within a consistent distance, but is it possible to have that $maxDistance refer to the distance field from the Message document?