index sparse mongodb code example Example: mongoose sparse index var User = new Schema({ name: { type: String, sparse: true } })