Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muhammadghazali/9857423 to your computer and use it in GitHub Desktop.
Save muhammadghazali/9857423 to your computer and use it in GitHub Desktop.
Muhammad Ghazali's Online Notes: Sails: Setup geospatial index saat bootstraping
module.exports.bootstrap = function(cb) {
// setup 2dsphere Index on `foo` collection
Foo.native(function(err, collection) {
collection.ensureIndex({
location: '2dsphere'
}, function(err, result) {
// callbacks gets two parameter:
// - an error object (if an error occured)
// - the name for the newly created index
return;
});
});
// It's very important to trigger this callack method when you are finished
// with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap)
cb();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment