Add unique index to token properties

This commit is contained in:
Shane Kilkelly 2017-09-21 15:06:42 +01:00
parent 441c207953
commit 95292a2e55

View file

@ -43,11 +43,13 @@ ProjectSchema = new Schema
tokens :
readOnly : {
type: String,
default: generateToken(14)
default: generateToken(14),
index: {unique: true}
}
readAndWrite : {
type: String,
default: Math.random().toString().slice(2, 10) + generateToken(12)
index: {unique: true}
}
tokenAccessReadOnly_refs : [ type:ObjectId, ref:'User' ]
tokenAccessReadAndWrite_refs : [ type:ObjectId, ref:'User' ]