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