Mongolian Geospatial Index and Meteor

I am wondering if the mongodb geospatial index with Meteor architecture can be used.

Minimongo does not implement geospatial indexes, but does this mean that we cannot use this mongo function on the server side?

For example, when using todos application, if we use the location on todo, it will be possible:

// Publish complete set of lists to all clients. Meteor.publish('todos', function (lon,lat) { return Todos.find({loc: {$near:[lon,lat]}}).limit(2); }); 

And on the client side:

 Meteor.subscribe('todos', lon, lat ); 
+13
source share
2 answers

Yes, you can use the MongoDB geospatial index within Meteor, and you can create this index from your Meteor application.

- Geospatial Search

I use the $within operator below, unlike the $near operator mentioned above, but this still applies:

 Meteor.publish('places', function(box) { return Places.find({ loc : { $within : { $box : box }}}); }); 

Reminder: these geological queries are only available on the server (currently).

- Creating a geospatial index from within Meteor (and not in the MongoDB shell)

 Places._ensureIndex({ loc : "2d" }); 

eg. You can use the above in bootstrap.js .

Also, you probably want to put your ensureIndex in Meteor.startup or perhaps when you insert some initial data.


Warning As mentioned here , the above method call to ensureIndex is the work of having an official way to call it, so please expect this to change.

Update : Now reflects changes in Meteor 0.5.0, see @Dror comment below.

+18
source

Yes, I think you can.

On the server side, Meteor delegates find / update / .. in the node-mongo-native call. You can see the code in packages / mongo -liveata / mongo_driver.js. And, as I know, node-mongo-native supports geospatial index.

+1
source

All Articles