Sunday, 2 April 2017

Mongoose - Independent Unique Constraints

I am trying to get two independent unique constraints on one Schema to work but...

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

... always creates a compound index which makes the following table valid:

name: "Foo", shortName: "Bar";
name: "Foo", shortName: "Foo";

Is there any way to make those unique contraints independent?



via Pat

No comments:

Post a Comment