SHARE
TWEET

Untitled

a guest Dec 15th, 2018 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "user_address": [
  2.         {
  3.             "location": {
  4.                 "coordinates": [
  5.                     78.486671,
  6.                     17.385044
  7.                 ],
  8.                 "type": "Point"
  9.             },
  10.             "_id": {
  11.                 "$oid": "5c1532422550c949e8b4f071"
  12.             },
  13.             "house_number": "New HUDA Layout",
  14.             "landmark": "Mehdipatnam, Hyderabad",
  15.             "full_address": "12-2-460/2 New HUDA Layout, Gudimalkapur, Mehdipatnam, Hyderabad, Telangana 500028, India",
  16.             "address_type": "1"
  17.         },
  18.         {
  19.             "location": {
  20.                 "coordinates": [
  21.                     78.44025914414988,
  22.                     17.388800281650862
  23.                 ],
  24.                 "type": "Point"
  25.             },
  26.             "_id": {
  27.                 "$oid": "5c153326b96927493404a264"
  28.             },
  29.             "house_number": "Viswash Nagar, Murad Nagar",
  30.             "landmark": "Hyderabad, Telangana",
  31.             "full_address": "Gudi Malkapur Rd, Viswash Nagar, Murad Nagar, Hyderabad, Telangana 500028, India",
  32.             "address_type": "1"
  33.         },
  34.         {
  35.             "location": {
  36.                 "coordinates": [
  37.                     77.39227006550277,
  38.                     28.520825283742465
  39.                 ],
  40.                 "type": "Point"
  41.             },
  42.             "_id": {
  43.                 "$oid": "5c1533b7b96927493404a265"
  44.             },
  45.             "house_number": "new ashok nagar",
  46.             "landmark": "natural suparmart",
  47.             "full_address": "A-87, Block A, Sector 92, Noida, Uttar Pradesh 201304, India",
  48.             "address_type": "1"
  49.         }
  50.     ],
  51.    
  52. const UserSchema = new Schema({
  53.   name: { type: String, required: true },
  54.   email: { type: String, required: true },
  55.   mobile: { type: String, required: true },
  56.   user_address:[{
  57.         house_number:{type: String},
  58.         landmark:{type: String},
  59.         full_address:{type: String},
  60.         address_type:{type: String, enum:['1','2']},
  61.         location: { type: { type: String }, coordinates: [Number] },
  62.     }],
  63. });
  64.  
  65. UserSchema.index({ "user_address.location": "2dsphere" });
  66.    
  67. const userAddressList = await User.find({
  68.       "user_address.location": {
  69.         $near: {
  70.           $maxDistance: 5000,
  71.           $geometry: { type: "Point", coordinates: [78.486671,17.385044] }
  72.         }
  73.       }, _id: req.decoded._id
  74.     }, { user_address: 1 });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top