Mongoose 4.0.2 doesn't create indexes automatically for some reason despite of its docs.
So I've found if you add {autoIndex: true} as it's shown bellow, it solves the issue.
var path = require('path');
module.exports = function (mongoose) {
var Schema = new mongoose.Schema({
name: {type: String, trim: true, required: true},
uuid: {type: String, required: true, unique: true, index: true},
device: {type: mongoose.Schema.Types.Mixed},
updated_at: {type: Date, default: Date.now}
}, {autoIndex: true});
return mongoose.model(path.basename(module.filename, '.js'), Schema);
};
Comments (0)
RSS Collapse / ExpandOnly registered and authorized users can leave comments. Login or Register