Last active
August 29, 2015 13:57
-
-
Save muhammadghazali/9857423 to your computer and use it in GitHub Desktop.
Muhammad Ghazali's Online Notes: Sails: Setup geospatial index saat bootstraping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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