Mongo geospatial index and Meteor Mongo geospatial index and Meteor mongodb mongodb

Mongo geospatial index and Meteor


Yes, you can use the MongoDB geospatial index within Meteor, and you can create that index from within your Meteor app too.

- Geospatial Search

I'm using the $within operator below, as opposed to the $near operator mentioned above, but this still applies:

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

Reminder: These kinds of geo queries are only available on the server (currently).

- Creating a Geospatial Index from within Meteor (rather than in a MongoDB shell)

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

e.g. You could use the above in your bootstrap.js.

Also, you'll probably want to put your ensureIndex in Meteor.startup, or perhaps when you're inserting some initial data.


Warning: As mentioned here, the above method of calling ensureIndex is a work around for want of an official way to call it, so please expect that this might change.

Update: now reflects changes in Meteor 0.5.0, see @Dror's comment below.


Yes, I think you can.

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