mohammedshahid096 / mosque_management

1 stars 0 forks source link

Use GeoJSON format #5

Open Gibigbig opened 3 weeks ago

Gibigbig commented 3 weeks ago

https://github.com/mohammedshahid096/mosque_management/blob/00443ec6170425908dfc47735f6c814b1e0b65cc/Backend/src/Schema/mosque.model.js#L34

Better to use GeoJSON format for coordinates and insure they are indexed as such so queries involving it are optimized. . Below is an example.



const locationSchema = new mongoose.Schema({
  coordinates: {
    type: {
      type: String,
      enum: ['Point'],
      required: true,
    },
    coordinates: {
      type: [Number], // Array of numbers [longitude, latitude]
      required: true,
    },
  },
});

// Ensure that coordinates are indexed for geospatial queries
locationSchema.index({ coordinates: '2dsphere' });

module.exports = mongoose.model('Location', locationSchema);```
mohammedshahid096 commented 3 weeks ago

Yes we can keep geo location data and also google map url etc..