在当前的Mongoose版本4.3.7中,您无法在方案中定义部分索引,但仍可以使用MongoDB 3.2的部分索引。
您只需要使用本机驱动程序创建索引。
// ScheduleModel is a Mongoose ModelScheduleModel.collection.createIndex({"type" : 1 } , {background:true , partialFilterexpression : { type :"g" }} , function(err , result){ console.log(err , result);});之后,每个与匹配的查询
partialFilterexpression都将被索引。



