I have this code and it works:
var JobModel = null;
var get = function (cb) {
if(JobModel === null){
JobModel = mongoDB.model('jobs', jobSchema);
//TODO: db.collection.createIndex(keys, options)
JobModel.ensureIndexes(function(err){
if(err){
console.log(colors.bgRed(err));
}
cb(err,JobModel);
});
}
else{
cb(null,JobModel);
}
};
but I can't find any reference to ensureIndexes in the MongoDB documentation.
what is the difference between ensureIndex and ensureIndexes and createIndex?