2017-03-13 10 views
1

Mongoにエンティティの場所を格納しようとしています。私は入力されたいくつかの場所に問題があるようです。私が得るエラーはMongoError:球形のCRSにジオメトリを投影できません

です。MongoError:ジオキーを抽出できません:球形CRSにジオメトリを投影できません:[26.1633829、91.78194759999997]。インデックスに何か問題がありますか?私は

var mongoose = require('mongoose'); 
var Schema = mongoose.Schema; 

var modelSchema = new mongoose.Schema({ 

email: {type: String, lowercase: true}, 
username: {type: String, unique: true, lowercase: true, index: true}, 
branchName: String, 
address: { 
    address1: String, 
    address2: String, 
    locality: String, 
    pinCode: Number, 
    sublocality_level_2: String, 
    sublocality_level_1: String, 
    localityName: String, 
    administrative_area_level_2: String, 
    administrative_area_level_1: String, 
    country: String, 
    postal_code: String, 
    geo: { 
     type: [Number], 
     index: '2dsphere' 
    } 
}, 
branchPAN: String, 
branchType: String,   
}); 

module.exports = mongoose.model('SampleModel', modelSchema); 

答えて

0

私は100%わからないんだけど、私はあなたの問題は、ポイントの種類から来ていると思いますが、以下のように私のスキーマがある

3.4のMongoDBバージョンに取り組んでいます。ドキュメンテーションをチェックすると、2dsphereにGeoJSONを使うべきだと言われました。 mongoose-geojson-schema

+0

ありがとうございました。 –

2

もっとここにビットを読んだ後:このためマングースプラグインがあり

{ type: "<GeoJSON type>" , coordinates: <coordinates> } 

:代わりに数字の単一のアレイの

The 2dsphere index supports data stored as GeoJSON objects and as legacy coordinate pairs (See also 2dsphere Indexed Field Restrictions). For legacy coordinate pairs, the index converts the data to GeoJSON Point. For details on the supported GeoJSON objects, see GeoJSON Objects.

、あなたは次の形式を使用する必要があります。 https://docs.mongodb.com/manual/reference/geojson/#point

重要 常にリストは経度、緯度の順に座標そのリンクの音があります。

私は別の方法で値を渡していました。

+0

はい私の仕事 –

関連する問題