加索引

This commit is contained in:
wh_zcy 2023-01-31 18:19:45 +08:00
parent a0e7048039
commit f13707e51b
3 changed files with 13 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)
type ModelFriend struct {
@ -21,6 +22,10 @@ func (this *ModelFriend) Init(service core.IService, module core.IModule, comp c
this.TableName = comm.TableFriend
err = this.MCompModel.Init(service, module, comp, options)
this.moduleFriend = module.(*Friend)
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 (
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)
type ModelRtaskRecord struct {
@ -22,6 +23,10 @@ func (this *ModelRtaskRecord) Init(service core.IService, module core.IModule, c
err = this.MCompModel.Init(service, module, comp, options)
this.moduleRtask = module.(*ModuleRtask)
this.service = service
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
})
return
}

View File

@ -49,6 +49,9 @@ func (this *ModelSociaty) Init(service core.IService, module core.IModule, comp
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "_id", Value: bsonx.Int32(1)}},
})
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "name", Value: bsonx.Int32(1)}},
})
this.module = module.(*Sociaty)
this.service = service
this.EventApp = event_v2.NewApp()