Mongoose - how to add 2dsphere index on custom type? Mongoose - how to add 2dsphere index on custom type? mongoose mongoose

Mongoose - how to add 2dsphere index on custom type?


I think you cannot use Mongoose-geojson-schema that way, it messes up the 'type' attributes - try this:

var mySchema = new Schema({    district: {        type: String,        trim: true,        unique: true,        required: true    },    area: GeoJSON.FeatureCollection }); mySchema.path('area').index({ type: '2dsphere'});