Mongoose - Independent Unique Constraints Mongoose - Independent Unique Constraints mongoose mongoose

Mongoose - Independent Unique Constraints


from unique index documentation :

You can also enforce a unique constraint on compound indexes. These indexes enforce uniqueness for the combination of index keys and not for either key individually.

so to achieve this you'll need to create a unique index on each field, like this:

var Game = new Schema(  {    name: { type: String, unique: true },     shortName: { type: String, unique: true }  })