Merge pull request #422 from hantmac/develop

Add Unique index for 'key'
This commit is contained in:
Marvin Zhang
2020-01-04 17:52:00 +08:00
committed by GitHub

View File

@@ -93,5 +93,14 @@ func InitMongo() error {
// 赋值给全局mongo session
Session = sess
}
//Add Unique index for 'key'
keyIndex := mgo.Index{
Key: []string{"key"},
Unique: true,
}
s, c := GetCol("nodes")
defer s.Close()
c.EnsureIndex(keyIndex)
return nil
}