Partial indexes in mongodb / mongoose
Now it's possible natively with Mongoose +4.6.1
Book.index({user: 1, author: 1, complete: 1}, {unique: true, partialFilterExpression: {complete: true}});
In the current Mongoose version 4.3.7 you cannot define partial indexes in the scheme, but you can still use Partial Indexes of MongoDB 3.2.
You just have to create the indexes using the native driver.
// ScheduleModel is a Mongoose ModelScheduleModel.collection.createIndex({"type" : 1 } , {background:true , partialFilterExpression : { type :"g" }} , function(err , result){ console.log(err , result);});
After that, every query that matches the partialFilterExpression
will be indexed.