打赏

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分别表示升序索引和降序索引

posted @ 2020-02-05 13:18  孟繁贵  阅读(1266)  评论(0)    收藏  举报
TOP