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

相关文章:

  • 2021-11-03
  • 2021-11-28
  • 2021-05-12
  • 2021-11-24
  • 2021-09-29
  • 2021-09-15
  • 2021-07-28
  • 2021-12-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2021-10-14
  • 2021-11-29
  • 2021-09-02
相关资源
相似解决方案