mongoose place code example
Example 1: mongoose geojson
const citySchema = new mongoose.Schema({
name: String,
location: {
type: {
type: String,
enum: ['Point'],
required: true
},
coordinates: {
type: [Number],
required: true
}
}
});
Example 2: mongoose geojson
const polygonSchema = new mongoose.Schema({
type: {
type: String,
enum: ['Polygon'],
required: true
},
coordinates: {
type: [[[Number]]],
required: true
}
});
const citySchema = new mongoose.Schema({
name: String,
location: polygonSchema
});