Mongoose: how to define a combination of fields to be unique?

You can define a unique compound index using an index call on your schema:

person.index({ firstName: 1, lastName: 1}, { unique: true });

Leave a Comment