mongoose 创建索引
字段级别
var animalSchema = new Schema({ name: String, type: String, tags: { type: [String], index: true } // field level });
schema级别
animalSchema.index({ name: 1, type: -1 }); // schema level
1和-1分别表示升序索引和降序索引
来源:https://www.cnblogs.com/mengfangui/p/12263358.html