uid 创建索引

This commit is contained in:
meixiongfeng 2022-07-12 11:06:07 +08:00
parent bd548b5ff5
commit 1ef8ec4073

View File

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