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.
a darren
source share