As the title suggests i tried to add a 2dsphere index on my GeoPoints attributes on LoopbackJs. My MongoDB shell version is 3.2.3 - so it should do.
Here are my tries so far:
Adding enableGeoIndexing in my server/datasource.js
{ ... "myDs": { "host": "localhost", "port": 27017, "database": "myDB", "name": "myDs", "connector": "mongodb", "enableGeoIndexing": true }
... }
Nothing seemed to change.
Adding indexes the Loopback way + having an autoupdate script:
{ "name": "NsUser", "base": "User", "idInjection": true, "options": { "validateUpsert": true }, "indexes": { "geopoint_index": { "geopoint": "2dsphere" } }, "properties": { "created": { "type": "date" }, "firstname": { "type": "string" }, "lastname": { "type": "string" }, "geopoint": { "type": "geopoint" }, ... } … }
And I'm getting an error :
"ok" : 0,
"errmsg" : "Can't extract geo keys: { _id: ObjectId('5807689f01723b3ca6ba08e5'), created: new Date(1426545369000), email: \"[email protected]\", firstname: \"Louis\", lastname: \"L\", geopoint: { lat: -17.52243049, lng: -149.54396636 } } can't project geometry into spherical CRS: { lat: -17.52243049, lng: -149.54396636 }",
"code" : 16755