我在文档中有一个位置数组,我想在该数组上添加一个 2dSpere 索引。那可能吗?
var LocationSchema = new Schema({
type: { type: String, required: true },
geometry: {
type: { type: String, required: true },
coordinates: { type: Array, required: true}
},
properties: Schema.Types.Mixed
});
// Collection to hold users
var UserSchema = new Schema({
username: { type: String, required: true, unique: true },
locations: [LocationSchema]
},{
versionKey: false
}
);
如何在位置数组的几何字段上添加 2DSphere 索引?