From 1ef8ec4073945f8009ceb4779c677299ed2f4645 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 12 Jul 2022 11:06:07 +0800 Subject: [PATCH] =?UTF-8?q?uid=20=E5=88=9B=E5=BB=BA=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/model_hero.go | 6 ++++++ 1 file changed, 6 insertions(+) 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 }