var userSchema = new db.Schema({ email: { type: String, unique: true, lowercase: true }, password: { type: String, select: false }, company_name: String, location_verified: { type:Boolean, default:false}, account_verified: { type:Boolean, default:false}, date_joined: {type:Date, default:Date.now}, business_details: { business_phone: String, business_email: String, business_location:[] }})
userSchema.index({ 'business_detail.business_location': '2d' });var User = db.model('User', userSchema); var limit = req.query.limit || 10; // get the max distance or set it to 8 kilometers var maxDistance = req.query.distance || 8; // we need to convert the distance to radians // the raduis of Earth is approximately 6371 kilometers maxDistance /= 6371; // get coordinates [ <longitude> , <latitude> ] var coords = []; coords[0] = 101.6833; coords[1] = 3.1333; // find a location User.find({ 'business_details.business_location': { $near: coords, $maxDistance: maxDistance } }).limit(limit).exec(function(err, locations) { if (err) { console.log("The ERROR:"+err); //return res.json(500, err); } console.log("The RESULT:"+locations); //res.json(200, locations); });To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/d1478147-685a-4f65-a67e-8d034014c7d1%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.