2

ドキュメント内に位置の配列があり、その配列に 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 インデックスを追加するにはどうすればよいですか?

4

2 に答える 2

6

https://github.com/LearnBoost/mongoose/blob/master/examples/geospatial/geoJSONSchema.js#L19

LocationSchema.index({ 'ジオメトリ' : '2dsphere' });

于 2013-08-13T20:45:03.237 に答える