I'm using mogoosejs and have a data model:
var UserSchema = new Schema({
username: {type: String, required: true},
location: {type: [Number], required: true}, // [Long, Lat]
created_at: {type: Date, default: Date.now},
updated_at: {type: Date, default: Date.now}
});
Now on that schema I want to perform a query that will find all the users within certain area, so I did as follows:
var query = User.find({});
if(distance){
query = query.where('location').near({ center: {type: 'Point', coordinates: [long, lat]},
maxDistance: distance * 1609.34, spherical: true});
}
So that works super well, but now I want to add another parameter to this query - date. So I want to find all users within a specific location and that created their accound during last 16 hours... How should I modify my query to get all those results? Thanks a lot for any clues!