I've written an application using sails.js framework. http://sailsjs.org/#!documentation I cannot manage to run an ensureindex in the controller. What is the way to run an ensureIndex query in sails.js?
You can use the .native() method to run any native Mongo command in Sails. In this case, assuming a model called User, it would be:
User.native(function(err, collection) {
collection.ensureIndex("username",callback)
});
Alhough in most cases you probably want to do things like ensureIndex in the Mongo console when setting up your DB, not in realtime in your app...