Spaces:
Sleeping
Sleeping
| const mongoose = require('mongoose'); | |
| const locationSchema = new mongoose.Schema({ | |
| name: { | |
| type: String, | |
| required: true | |
| }, | |
| description: String, | |
| address: String, | |
| location: { | |
| type: { | |
| type: String, | |
| enum: ['Point'], | |
| default: 'Point' | |
| }, | |
| coordinates: { | |
| type: [Number], | |
| required: true | |
| } | |
| }, | |
| suggestedBy: { | |
| type: mongoose.Schema.Types.ObjectId, | |
| ref: 'User' | |
| }, | |
| images: [String] | |
| }, { timestamps: true }); | |
| locationSchema.index({ location: '2dsphere' }); | |
| const Location = mongoose.model('Location', locationSchema); | |
| module.exports = Location; | |