7

Sailsjs/Waterline は現在 POINT タイプまたは JSON を使用した地理空間インデックスをサポートしていないようです。

特定のアダプターが地理空間データ型をサポートするようにスキーマをカスタマイズする方法はありますか?

そうでない場合、2 番目の ORM を Waterline に統合する方法はありますか?

4

2 に答える 2

1

Sails.js では、地理空間インデックス作成のために MongoDB (npm install --save Sails-mongo) が必要です。さらに、config/bootstrap.js で 2dindex が作成されるようにする必要があります (特定のモデル名と属性名を必ず置き換えてください)。ニーズ):

module.exports.bootstrap = function(cb) {

  // Ensure we have 2dsphere index on coordinates attribute of Place.
  sails.models.modelname.native(function (err, collection) {
    collection.ensureIndex({ attributename: '2dsphere' }, function () {

    // It's very important to trigger this callback method when you are finished
    // with the bootstrap!  (otherwise your server will never lift, since it's waiting on the bootstrap)
    cb();

    });
  });

};

また、ネイティブの MongoDB 地理空間クエリを使用する必要があることにも注意してください。これは質問の範囲を超えています。ここに実装例を投稿しました

于 2016-01-30T22:32:33.660 に答える