diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index f184a2c72..be52221c1 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -11,6 +11,8 @@ import ( mengine "github.com/dengsgo/math-engine/engine" "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type ModelHero struct { @@ -22,6 +24,10 @@ func (this *ModelHero) Init(service core.IService, module core.IModule, comp cor err = this.MCompModel.Init(service, module, comp, options) this.moduleHero = module.(*Hero) this.TableName = "hero" + // 通过uid创建索引 + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return }