我正在使用Mongoose和Mongoose-geojson-schema,但是我不能在我的字段中添加2dsphere索引:
new Schema({
district: {
type: String,
trim: true,
unique: true,
required: true
},
area: {
type: GeoJSON.FeatureCollection,
index: '2dsphere'
}
});得到这样的错误:
/Users/dmitri/api/node_modules/mongoose/lib/schema.js:479
throw new TypeError('Undefined type `' + name + '` at `' + path +
^
TypeError: Undefined type `2dsphere` at `area.index`
Did you try nesting Schemas? You can only nest using refs or arrays.发布于 2015-10-21 03:42:52
我认为你不能这样使用Mongoose-geojson-schema,它会弄乱'type‘属性--试试这个:
var mySchema = new Schema({
district: {
type: String,
trim: true,
unique: true,
required: true
},
area: GeoJSON.FeatureCollection
});
mySchema.path('area').index({ type: '2dsphere'});https://stackoverflow.com/questions/33240313
复制相似问题