db创建索引

This commit is contained in:
meixiongfeng 2023-06-15 11:30:51 +08:00
parent dca0850ff3
commit cb1c32f356
5 changed files with 23 additions and 0 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}