Is there a built-in way to say that a field should be unique if it is not null. For example, I want users to have a unique phone number, but this is not a required field. So it can be null, and hence it breaks the unique constraint if another user is added without a phone number.
This is almost the same question: mongoDB/mongoose: unique if not null but with newer versions of both mongoose and mongodb, I guess there should be a better way to achieve this.