mongoose 创建索引

牧云@^-^@ 提交于 2020-02-05 13:31:34

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!