From cb1c32f3566cf783fdf858da9b8a35c8cb0de87f Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 15 Jun 2023 11:30:51 +0800 Subject: [PATCH] =?UTF-8?q?db=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/enchant/model_rank.go | 5 +++++ modules/hero/model_record.go | 4 ++++ modules/hero/model_talent.go | 5 +++++ modules/hunting/model_rank.go | 5 +++++ modules/library/model_fetterstory.go | 4 ++++ 5 files changed, 23 insertions(+) diff --git a/modules/enchant/model_rank.go b/modules/enchant/model_rank.go index 2d8f8353c..8bed3f9ae 100644 --- a/modules/enchant/model_rank.go +++ b/modules/enchant/model_rank.go @@ -10,6 +10,8 @@ import ( "go_dreamfactory/sys/db" "github.com/go-redis/redis/v8" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type ModelRank struct { @@ -21,6 +23,9 @@ func (this *ModelRank) Init(service core.IService, module core.IModule, comp cor this.TableName = comm.TableEnchantRank // 挑战记录 err = this.MCompModel.Init(service, module, comp, options) this.moduleEnchant = module.(*Enchant) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return } diff --git a/modules/hero/model_record.go b/modules/hero/model_record.go index 0caf230f3..419509cd8 100644 --- a/modules/hero/model_record.go +++ b/modules/hero/model_record.go @@ -9,6 +9,7 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) // 记录一些扩展数据 图鉴 改名次数等 @@ -19,6 +20,9 @@ type ModelRecord struct { func (this *ModelRecord) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.TableName = comm.TableUserRecord err = this.MCompModel.Init(service, module, comp, options) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return } diff --git a/modules/hero/model_talent.go b/modules/hero/model_talent.go index 9a4793dab..798b2efc8 100644 --- a/modules/hero/model_talent.go +++ b/modules/hero/model_talent.go @@ -9,6 +9,8 @@ import ( "go_dreamfactory/pb" "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) // 英雄天赋组件 @@ -21,6 +23,9 @@ func (this *ModelTalent) Init(service core.IService, module core.IModule, comp c this.TableName = comm.TableTalent err = this.MCompModel.Init(service, module, comp, options) this.module = module.(*Hero) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return } diff --git a/modules/hunting/model_rank.go b/modules/hunting/model_rank.go index f2d307f7f..00613dbce 100644 --- a/modules/hunting/model_rank.go +++ b/modules/hunting/model_rank.go @@ -10,6 +10,8 @@ import ( "go_dreamfactory/sys/db" "github.com/go-redis/redis/v8" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type ModelRank struct { @@ -21,6 +23,9 @@ func (this *ModelRank) Init(service core.IService, module core.IModule, comp cor this.TableName = comm.TableHuntingRecord // 挑战记录 err = this.MCompModel.Init(service, module, comp, options) this.moduleHunting = module.(*Hunting) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return } diff --git a/modules/library/model_fetterstory.go b/modules/library/model_fetterstory.go index 185ecd248..29aaab377 100644 --- a/modules/library/model_fetterstory.go +++ b/modules/library/model_fetterstory.go @@ -9,6 +9,7 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" ) type modelFetterstory struct { @@ -22,6 +23,9 @@ func (this *modelFetterstory) Init(service core.IService, module core.IModule, c err = this.MCompModel.Init(service, module, comp, options) this.module = module.(*Library) this.service = service + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) return }