Reputation: 2909
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?
Upvotes: 1
Views: 355
Reputation: 24958
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...
Upvotes: 1