mongoose 创建索引
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分别表示升序索引和降序索引
作者:孟繁贵 Email:meng010387@126.com 期待共同进步!

浙公网安备 33010602011771号